在Catalina,Python/Python3,pip/pip3,PATH,zshrc等中使用zsh时遇到问题 [英] Problems using zsh with Catalina, Python/Python3, pip/pip3, PATH, zshrc, etc
问题描述
我最近更新了Catalina和默认的zsh.我可能在过渡过程中弄乱了路径,目前我正在尝试整理Python3.7,pip3,命令行PATH和我的zshrc文件的位置.
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.
似乎/usr/bin,/usr/local/bin,/usr/local/Cellar/python和/Users/[user]/.local/bin中包含潜在的冗余文件
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
以下是命令的复制品:
$ 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
有人可以帮我解决所有这些问题吗?据我了解:我只需要Python2.x用于操作系统;与Catalina一起使用时,我现在应该将Python3.x 仅存储在我的用户中(而不是在/usr中)?pip3是随Python3.x自动安装的(尽管我的返回一个错误),并且还应该安装在我的User中而不是/usr中?此外,我的$ PATH仍然包含残留物,例如Anaconda,此后我将其删除了...如何/在何处更新我的$ PATH?在zshrc文件中?
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?
推荐答案
在全新安装Catalina之后,我遇到了此问题.我也在使用 zsh
.
I've experienced this issue after a clean installation of Catalina. I'm also using zsh
.
我做错了什么:
我使用以下方法安装了新版本的 pip
:
I've installed a new version of pip
by using:
sudo pip3 install --upgrade pip
根据提示.但是,这不适用于Apple的 python
,因为路径不正确.相反,应该使用 sudo -H
.
as prompted. However, this will not work with Apple's python
, as the path will not be correct. Instead, sudo -H
should be used.
我如何固定点子:
幸运的是, python3 -m pip
仍可作为 pip3
的解决方法.
Fortunately, python3 -m pip
still works as a workaround for pip3
.
安装旧版本的 pip
(对于我来说, 19.3.0
就足够了):
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
然后再次升级:
sudo -H python3 -m pip install --upgrade pip
我希望这也能解决您的问题.
I hope this will also solve your issue.
这篇关于在Catalina,Python/Python3,pip/pip3,PATH,zshrc等中使用zsh时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!