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

笑着哭i 提交于 2021-02-17 21:29:18

问题


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?


回答1:


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.




回答2:


I had the same issue as you. Solved with

brew install python3



回答3:


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




回答4:


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.




回答5:


I had a similar problem. You can use

rehash

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




回答6:


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



来源:https://stackoverflow.com/questions/58423609/problems-using-zsh-with-catalina-python-python3-pip-pip3-path-zshrc-etc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!