我在 Ubuntu 12.10 上搞砸了 Python Pip 的系统版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16237490/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 22:05:16  来源:igfitidea点击:

I screwed up the system version of Python Pip on Ubuntu 12.10

pythonpipubuntu-12.10

提问by dartdog

I wanted to update pip on my main install of Python, specifically to get the list command. Which also includes the list- updates capability.

我想在我的主要 Python 安装上更新 pip,特别是为了获取 list 命令。其中还包括列表更新功能。

So I ran:

所以我跑了:

sudo pip install --upgrade pip

All looked good on the install but then I went to run pip and got this: (end of install included if it helps)

安装时一切看起来都不错,但后来我去运行 pip 并得到了这个:(如果有帮助,包括安装结束)

Installing pip script to /usr/local/bin
    Installing pip-2.7 script to /usr/local/bin
Successfully installed pip
Cleaning up...
tom@tom-sam:~$ pip list -o
bash: /usr/bin/pip: No such file or directory
tom@tom-sam:~$ pip
bash: /usr/bin/pip: No such file or directory

Somewhat obviously I'm hosed since this is my system install of python.. I read a few answers here but have not been able to determine the easiest fix.

有点明显我被冲洗了,因为这是我的python系统安装..我在这里阅读了一些答案,但无法确定最简单的修复方法。

采纳答案by Martin Mohan

I had the same message on linux.

我在 linux 上有同样的消息。

/usr/bin/pip: No such file or directory

but then checked which pip was being called.

但随后检查了正在调用哪个 pip。

$ which pip
/usr/local/bin/pip 

On my debian wheezy machine I fixed it doing following...

在我的 debian wheezy 机器上,我按照以下步骤修复了它...

/usr/local/bin/pip uninstall pip  
apt-get remove python-pip  
apt-get install python-pip  

====================================
This was due to mixup installing with apt-getand updating with pip install -U pip.

==================================
这是由于apt-getpip install -U pip.

These also installed libraries at 2 different places which caused problems for me.

这些还在 2 个不同的地方安装了库,这给我带来了问题。

/usr/lib/python2.7/dist-packages  
/usr/local/lib/python2.7/dist-packages

回答by boredcoding

Before getting happy with apt-get removes and installs. It's worthwhle to reset your bash cache.

在对 apt-get 删除和安装感到满意之前。重置 bash 缓存是值得的。

hash -r

Bash will cache the path to pip using the distrubtion install (apt-get) which is /usr/bin/pip. If you're still in the same shell session, due to the cache, after updating pip from pip your shell will still look in /usr/bin/ and not /usr/local/bin/

Bash 将使用 /usr/bin/pip 的 distrubtion install (apt-get) 缓存 pip 的路径。如果您仍然在同一个 shell 会话中,由于缓存的原因,从 pip 更新 pip 后,您的 shell 仍将在 /usr/bin/ 中查找,而不是 /usr/local/bin/

for example:

例如:

$apt-get install python-pip
$which pip
/usr/bin/pip

$pip install -U pip
$which pip
/usr/bin/pip

$hash -r
$which pip
/usr/local/bin/pip

回答by サルバドル

I had the same problem as @dartdog and thanks to @Martin Mohan and @warvariuc I was able to fully uninstall pip

我遇到了与 @dartdog 相同的问题,感谢 @Martin Mohan 和 @warvariuc,我能够完全卸载 pip

Unfortunately using the command

不幸的是使用命令

apt-get install python-pip 

Was installing an old version of pip so after doing

在安装旧版本的 pip 之后

/usr/local/bin/pip uninstall pip  
apt-get remove python-pip  

To install the latest pip version I got the get-pip.pyfile from https://bootstrap.pypa.io/get-pip.py

要安装最新的 pip 版本,我从https://bootstrap.pypa.io/get-pip.py获得了get-pip.py文件

And once in the file directory from the command line executed the command python get-pip.pyhope it helps someone

一旦在命令行中的文件目录中执行命令python get-pip.py希望它可以帮助某人

Also some of the commands need sudo good luck!!

还有一些命令需要 sudo 祝你好运!!

回答by Alex

I had the same problem running Mint 18.1 after upgrading pip. I got it resolved simply by closing and opening the terminal.

升级 pip 后,我在运行 Mint 18.1 时遇到了同样的问题。我只是通过关闭和打开终端来解决它。

回答by Adam Trizuljak

I was using pip with Python 3.5.2. Then I messed up during upgrade to Python 3.6 and I decided to revert to 3.5. After I removed pip-3.6, pip3was pointing to /usr/local/bin/pip3, but the symlink to the actual pip install directory was missing. I fixed it with

我在 Python 3.5.2 中使用 pip。然后我在升级到 Python 3.6 的过程中搞砸了,我决定恢复到 3.5。删除 pip-3.6 后,pip3指向/usr/local/bin/pip3,但缺少指向实际 pip 安装目录的符号链接。我用

sudo ln -s /usr/bin/pip3 /usr/local/bin/pip3

sudo ln -s /usr/bin/pip3 /usr/local/bin/pip3

回答by Jrct

These two answers in other threads helped me out:

其他线程中的这两个答案帮助了我:

  1. Re-installing pip: https://stackoverflow.com/a/49997795/9377685

  2. pip started working after step 1, but kept showing an error:

  1. 重新安装pip:https: //stackoverflow.com/a/49997795/9377685

  2. pip 在第 1 步后开始工作,但一直显示错误:

RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown. warnings.warn(warning, RequestsDependencyWarning)

RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown. warnings.warn(warning, RequestsDependencyWarning)

This answer helped in upgrading the cryptography and PyOpenSSL: https://stackoverflow.com/a/51284877/9377685

这个答案有助于升级密码学和 PyOpenSSL:https://stackoverflow.com/a/51284877/9377685