Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using zsh with Catalina, Python/Python3, pip/pip3, PATH, zshrc, etc

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?

like image 991
OJT Avatar asked Oct 17 '19 01:10

OJT


3 Answers

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.

like image 99
Jonas Drotleff Avatar answered Oct 07 '22 00:10

Jonas Drotleff


I had a similar problem. You can use

rehash

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

like image 37
00schneider Avatar answered Oct 06 '22 23:10

00schneider


I had the same issue as you. Solved with

brew install python3
like image 30
Stev3 Avatar answered Oct 06 '22 22:10

Stev3