16

I recently updated to Catalina and the default zsh. I probably messed up paths during the transition, and I'm currently trying to sort out the locations of Python3.7, pip3, the command-line PATH and my zshrc file.

It looks as if there are potentially redundant files contained within /usr/bin, /usr/local/bin, /usr/local/Cellar/python and /Users/[user]/.local/bin

The following are reproductions of commands:

$ which python3
/usr/bin/python3
$ which python
/usr/bin/python
$ which pip
pip not found
$ which pip3
/usr/bin/pip3
$ pip3 -V
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/usr/bin/pip3", line 10, in <module>
    sys.exit(main())
TypeError: 'module' object is not callable
$ cat ~/.zshrc
export PATH=$PATH:/usr/local/bin:/usr/bin
$ echo $PATH
/Users/[user]/.local/bin:/bin:/usr/bin:/usr/local/bin:/Users/[user]/anaconda3/bin:/Users/[user]/anaconda3/bin:/Users/[user]/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/[user]/anaconda3:/Library/TeX/texbin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin:/usr/local/bin:/usr/bin:/usr/local/bin:/usr/bin

Can anyone help me troubleshoot all of this? From what I understand: I only need Python2.x for OS; with Catalina I should now be storing Python3.x only within my User (not in /usr)? pip3 is automatically installed with Python3.x (although mine is returning an error) and also should be installed within my User and not in /usr? Also, my $PATH still contains remnants, e.g., Anaconda, which I have since removed... how/where do I update my $PATH? Within the zshrc file?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
OJT
  • 887
  • 1
  • 10
  • 26
  • 1
    It seems that regardless of edits (e.g., I removed anaconda from my /etc/paths file because I am no longer using it), which python and which python3 point to /usr/bin instead of another location. – OJT Oct 17 '19 at 01:54
  • 2
    `which -a` will show you *all* possible paths that match, in the order they appear in `PATH`. That information may prove useful. – chepner Oct 18 '19 at 16:03
  • 1
    I am experiencing the same issue after updating `pip` using `sudo pip3 install ---upgrade pip` on Catalina. However, using `python3 -m pip` sitll works. You could use this as a workaround. – Jonas Nov 05 '19 at 15:47

6 Answers6

13

I've experienced this issue after a clean installation of Catalina. I'm also using zsh.

What I did wrong:

I've installed a new version of pip by using:

sudo pip3 install --upgrade pip

as prompted. However, this will not work with Apple's python, as the path will not be correct. Instead, sudo -H should be used.

How I fixed pip:

Fortunately, python3 -m pip still works as a workaround for pip3.

Install an older version of pip (in my case, 19.3.0 was sufficient):

sudo -H python3 -m pip install --upgrade pip==19.3.0

and then upgrade again:

sudo -H python3 -m pip install --upgrade pip

I hope this will also solve your issue.

Jonas
  • 725
  • 5
  • 23
  • This didn't solve my problem with mkdocs, but a version of it did. In case it helps anyone else, mkdocs appears to require pip vs pip3 `sudo -H python3 -m pip install --upgrade pip==19.3.0` `which pip` `pip install mkdocs` `mkdocs` – Glasgow Oct 19 '21 at 08:39
2

I had the same issue as you. Solved with

brew install python3
Stev3
  • 158
  • 1
  • 8
2

I had a similar problem. You can use

rehash

in your command line to update your paths. It solved the issue for me.

00schneider
  • 698
  • 9
  • 21
1

I solved the issue by deleting ~/Library/Python.

okkwon
  • 19
  • 1
  • 2
    Please whenever you answer a question or add any comment, make sure that it is in such a format which is understandable by other people and makes sense, if a new user comes in. – ashwin agrawal Nov 01 '19 at 23:05
1

I was also running in to this issue on a fresh install of MacOS Catalina with Kitty term emulator + ohmyzsh.

Reading this question led me to my .zshrc which still had the line commented

\#export PATH=$HOME/bin:/usr/local/bin:$PATH

I removed the comment, which added the $HOME/bin to the PATH

~/.zshrc

export PATH=$HOME/bin:/usr/local/bin:$PATH

This change allowed me to successfully run the pip3 command without the traceback error.

Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53
Hank
  • 11
  • 1
1

The solution didn't work for me. After reinstalling python3 with this command: brew reinstall python3 I did this:

sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install

I read it from this website: https://mikebeach.org/2020/02/08/pip3-crashes-on-macos-catalina/

I hope it helps you guys

pooria
  • 343
  • 2
  • 14