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?

2
  • Have you tried running in a virtual environment? Are you running an Anaconda distribution of Python?
    – Natsfan
    Commented Aug 25, 2020 at 22:39
  • Running on a physical server (2020 MacPro). Hadn't heard of Anaconda, but it sounds like it would be worth considering as a workaround. Commented Aug 26, 2020 at 17:04

2 Answers 2

1

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
2
  • I've just installed the latest version 2 and version 3 directly from python.org, and everything seems to work.
    – benwiggy
    Commented Aug 26, 2020 at 8:06
  • That might work for Mojave, but it won't for Catalina. Have a look at the commands in my question and you will see that /usr/bin/pip3 is binary. Commented Aug 26, 2020 at 16:50
0

enter image description here

This is just how Python environment is.


Before you reinstall Python, check first if you can use pip3.8 or pip. Otherwise, I recommend reinstalling Python with homebrew

3
  • Would Anaconda be another option?
    – uhoh
    Commented Aug 26, 2020 at 4:33
  • 1
    @uhoh It's been working fine for me for a long time. Easy to install, easy to cleanup. An issue is that I need to download some binaries people distribute only via pip, from the website or fiddle with conda build which takes a long time. pypi.org/project/<name>/#files .. docs.conda.io/projects/conda-build/en/latest
    – anki
    Commented Aug 26, 2020 at 6:11
  • (Love XKCD.) Homebrew is worthy suggestion (or MacPorts in my case) as a workaround, but it would be nice to get the installed version working. Commented Aug 26, 2020 at 16:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .