Why is pip3 referencing Python 2 instead of 3?
When I try to install Python pacakges using pip3
on macOS (Catalina) it searches Python 2 instead:
vger:~(61)+>- sudo -H pip3 install xattr
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already satisfied: xattr in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (0.6.4)
vger:~(62)+>- which pip3
/usr/bin/pip3
vger:~(63)+>- file /usr/bin/pip3
/usr/bin/pip3: Mach-O 64-bit executable x86_64
vger:~(64)+>- which python3
/usr/bin/python3
vger:~(65)+>-
Which means of course that I can't install extra packages on Python 3. Why is a utility dedicated to Python 3 accessing Python 2 paths?
Run
open /usr/bin/pip3 -a Textedit.app
Or general:
open $(which pip3) -a Textedit.app
The first line (shebang) would be point to python 2. Fix it by putting in the path to python 3 there.
I use conda environment, so for me it is:
#!/usr/local/opt/[email protected]/bin/python3.8
For you, it should be
#!/usr/bin/python3
or any other python executable that you want to use.
Alternate method is running pip by invoking python3.
python3 -m pip install xattr
- https://stackoverflow.com/a/51055589/