在Ubuntu中,pip和easy_install命令无法使用。已安装Python 2.7和3.4版本。

7
我是一个辅助翻译员。以下是您需要翻译的内容:

我对Python还很陌生。我使用的是Ubuntu 14.04,已经安装了python 2.7.6和python 3.4.0。我试图安装BeautifulSoup,但是失败了,因为出现了错误提示

The program 'pip' is currently not installed. 

我发现Python 3.4已经预装了pip。我尝试按照stackoverflow另一个问题中提到的方法:sudo easy_install pip 来安装pip。但是,这会出现错误信息sudo: easy_install: command not found。请问问题出在哪里?

3
首先尝试运行命令 sudo apt-get install python-setuptools - ceejayoz
你确定你正在使用Python 3.4吗?如果你输入 python --version,它会显示什么? - ceejayoz
https://docs.python.org/3/installing/ 上说,在3.4版本中,你应该使用 python -m pip install SomePackage 而不是 pip install SomePackage - ceejayoz
你也没有pip3命令吗? - Padraic Cunningham
@PadraicCunningham 没有,我不得不使用 easy_install 获取 pip3。 - mahacoder
显示剩余3条评论
3个回答

8

pip 现在已经变成了 python -m pip,如果是 Python 3.4,那么你需要使用 python3 -m pip,因为 Ubuntu 保留了 2.x 线路作为 python

Python 2.7 的 easy_install 包含在 python-setuptools 包中。安装完成后,运行 easy_install pip 即可为 Python 2.7 安装 pip。


是的,你说得对。当我尝试运行 python3 -m pip 时,出现了 /usr/local/bin: No module named pip 的错误。那么我该如何为 Python 3.4 获取 pip 呢? - mahacoder
@ak31 看起来这是相同的问题,有解决方案。 - ceejayoz

4

那么apt-get install python-pip怎么样?至少,Debian官方仓库中有python-pip,即使是从 wheezy 版本开始。


2
很遗憾,从2018年4月开始,python-setuptools不再附带easy_install。这是由于Matthias的更新所致: https://ubuntu.pkgs.org/18.04/ubuntu-main-i386/python-setuptools_39.0.1-2_all.deb.html 但是你仍然可以自行编译源代码,它确实有效。我刚刚尝试了sudo easy_install shodan,并成功运行。
git clone https://github.com/pypa/setuptools.git
cd ./setuptools
python3 bootstrap.py
sudo python3 setup.py install

希望这能帮到您。

谢谢!这个解决了今天的难题。Python-setuptools确实不再提供easy_install,但是有很多教程/答案说它会起作用。这节省了我很多时间。谢谢! - nelsonenzo
随时可以,兄弟。 - Kourosh Taheri-Golvarzi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接