Reputation: 1882
Installing packages using pip3, I can't seem to access them in my python3
interpreter.
I then checked that after the MacBook upgrade my python3 is in:
which python3
/usr/bin/python3
and my pip3 is in:
which pip3
/opt/homebrew/bin/pip3
I think pip3 is installing packages in homebrew
location and that is why system's native
python3 doesn't have access to?
pip3 --version
pip 23.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
How do I resolve it?
Upvotes: 0
Views: 2914
Reputation: 1882
Many thanks for @nneoneo. So this is what I did exactly to sort it.
I wanted to use the system python3
. I first checked and upgraded the pip3 for the system's python3:
python3 -m pip install --upgrade pip
I saw a warning in the upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages (21.2.4)
Collecting pip
Downloading pip-23.3.2-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 1.9 MB/s
Installing collected packages: pip
WARNING: The scripts pip, pip3, pip3.11 and pip3.9 are installed in '/Users/YOUR_USER_NAME/Library/Python/3.9/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-23.3.2
WARNING: You are using pip version 21.2.4; however, version 23.3.2 is available.
You should consider upgrading via the '/Applications/Xcode.app/Contents/Developer/usr/bin/python3 -m pip install --upgrade pip' command.
I then checked my $HOME/.bashrc
and noticed that it was pointing to the old python3
version:
/Users/YOUR_USER_NAME/Library/Python/3.8/bin
After upgrading the Mac, it comes with python3.9 so I just changed the above with:
/Users/YOUR_USER_NAME/Library/Python/3.9/bin
restart terminal and now which pip3 shows:
which pip3
/Users/YOUR_USER_NAME/Library/Python/3.9/bin/pip3
now if I install any packages using pip3
it will be using the system's python3 and not the home-brew.
hope this helps
Upvotes: 0
Reputation: 179372
It seems like you’ve installed Python via homebrew but the system python3 is taking precedence, probably because of the ordering of $PATH.
If you’d like to always use the Homebrew Python, consider adjusting $PATH. If on the other hand you’d like to always use the system Python, you can use python3 -m pip …
to use the pip for to the system Python.
Upvotes: 1