无法在ubuntu中安装pip?

2024-04-24 01:47:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我试过几次安装pip,但都没有成功。这是我的终端在尝试安装pip时的样子:

aman@aman-HP-Pavilion-Notebook:~$ sudo apt-get install python-pip

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

aman@aman-HP-Pavilion-Notebook:~$ pip

The program 'pip' is currently not installed. You can install it by typing:
sudo apt-get install python-pip

aman@aman-HP-Pavilion-Notebook:~$ sudo pip

sudo: pip: command not found

aman@aman-HP-Pavilion-Notebook:~$

Tags: installpipinstalledgetissudonotapt
2条回答

尝试使用以下命令:

sudo apt-get purge --auto-remove python-pip

sudo apt-get update

sudo apt-get -y install python-pip

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"

python get-pip.py

验证:

pip --help

pip -V

这个问题可能是Ubuntu 14.04universe存储库中提供的包。

如果不起作用,请从这里下载.deb:

https://packages.ubuntu.com/trusty/all/python-pip/download

右键单击.deb并安装它

问题可能是您的PC上安装了两个版本的Python2,它们位于不同的位置,其中一个副本的pip以某种方式被删除。因此,当您尝试为副本安装pip时,系统会说已经在另一个位置安装了pip,/usr/local/bin文件夹也缺少用于安装pip的pip文件。

我刚刚解决了这个问题,所以我将试着用一种方式来解释它,这样初学者也能正确地理解它

将已安装的pip文件复制到丢失的位置,而不是通过命令安装,因为command将检测已安装的pip。

解决方法非常简单:

在Ubuntu的终端(命令提示符)中运行这些命令

which pip

#获取已安装的pip文件的位置

cp location provided by which pip location where to copy pip file

希望有帮助。

相关问题 更多 >