bash 升级后pip坏了
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26302805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip broken after upgrading
提问by dl8
I did pip install -U easyinstall, and then pip install -U pip to upgrade my pip. However, I get this error now when trying to use pip:
我做了 pip install -U easyinstall,然后 pip install -U pip 升级我的 pip。但是,在尝试使用 pip 时,我现在收到此错误:
root@d8fb98fc3a66:/# which pip
/usr/local/bin/pip
root@d8fb98fc3a66:/# pip
bash: /usr/bin/pip: No such file or directory
This is on an ubuntu 12.04 in a docker image.
这是在 docker 映像中的 ubuntu 12.04 上。
回答by falsetru
One reason can be remembed locations.
原因之一是可以记住位置。
You can clear the cached locations by issuing following command:
您可以通过发出以下命令来清除缓存的位置:
hash -r
SIDENOTE: Instead of which
, using type
command, you can see the hashed location:
旁注:您可以看到散列位置,而不是which
使用type
命令:
$ type pip
pip is /usr/local/bin/pip
$ pip -V
pip 1.5.6 from /usr/local/lib/python2.7/dist-packages (python 2.7)
$ type pip
pip is hashed (/usr/local/bin/pip)
回答by ADTC
If doing hash -r
doesn't work, it's possible that the new pip
got installed in /usr/local/bin/
instead of the old one in /usr/bin/
. And it so happens that the new location is not in the list of paths searched for executables.
如果这样做hash -r
不起作用,则可能pip
安装了新的/usr/local/bin/
而不是旧的/usr/bin/
。碰巧新位置不在搜索可执行文件的路径列表中。
In that case, eitherfix the list of paths orcopy the executables:
在这种情况下,要么修复路径列表,要么复制可执行文件:
cp -p /usr/local/bin/pip* /usr/bin/
You may also hardlink the executables instead of copying them (this may ensure that future upgrades are done correctly).
您还可以硬链接可执行文件而不是复制它们(这可以确保未来的升级正确完成)。