A Damian
A Damian

Reputation: 121

Mac M1 python packages error after upgrade to python3

I am writing a project in NativeScript and I received the following error the last few days when I tried the commands: ns run ios or ns doctor.

Couldn't retrieve installed python packages.

The Python 'six' package not found.

enter image description here

I tried python and pip upgrade and also the command pip install six. Nothing of them fixed the problem.

I believe that is not a NativeScript issue, is about the configuration of the python packages in my machine. I mention that I am using a MacBook with M1 chip and it is running the 12.5 OS version.

I will appreciate any suggestions on this situation.

Upvotes: 1

Views: 2387

Answers (3)

GildarD Alvarado
GildarD Alvarado

Reputation: 26

After some searching, the solution that worked for me was to install pyenv, a Python version manager. You can find the repository here: pyenv.

In my .zshrc file, I had Python 3 configured with the following path: /Library/Frameworks/Python.framework/Versions/3.12/bin/python3. (Your path might differ or you might not have this path, which is okay.)

I commented out that line and set up pyenv instead. You can configure and install pyenv. After that, I switched to the required Python version using pyenv. Once I had the correct version set up, everything worked as expected.

Upvotes: 0

Kamil Kafoor
Kamil Kafoor

Reputation: 306

Try doing it with the python virtual environment. Following are the steps.

  1. Create a virtual environment.
  2. Activate the virtual environment.
  3. Run the pip install command with the virtual environment active.

Implement as follows:

  • use correct version of Python when creating VENV

python3 -m venv venv

  • activate on Unix or MacOS

source venv/bin/activate

  • activate on Windows (cmd.exe)

venv\Scripts\activate.bat

  • activate on Windows (PowerShell)

'venv\Scripts\Activate.ps1'

  • install the required package in the virtual environment

python3 -m pip install --upgrade pip

python3 -m pip install six

Note: This works only when you are in the virtual environment.

Upvotes: 0

A Damian
A Damian

Reputation: 121

Lastly, I found the solution. It was about the python folder into the path /usr/local/bin/python

You could check it by the following command: where python

In my case this folder is missing, perhaps I deleted it after the upgrade of the python3.

That was a mistake both folders should exist on this path!

If you type: where python you should receive: /usr/local/bin/python

If you type: where python3 you should receive: /usr/local/bin/python3

In order to fix the error, I installed python again by using the brew install pyenv this suggestion helps me to install it properly.

In the end, in order to eliminate all errors I installed the Python six package by using the command: pip install --ignore-installed six

Upvotes: 2

Related Questions