pip,easy_install 命令在 Ubuntu 中不起作用。 Python 2.7 和 3.4 已安装

pip, easy_install commands not working in Ubuntu. Python 2.7 and 3.4 are installed

我是 python 的新手。我正在使用 Ubuntu 14.04 并安装了 python 2.7.6 和 python 3.4.0。我试图安装 BeautifulSoup 但无法安装,因为我收到一条错误消息

The program 'pip' is currently not installed. 

我发现它与 python 3.4 捆绑在一起。我尝试使用 sudo easy_install pip 安装 pip,如 Whosebug 上的另一个问题所述。但这会产生错误 sudo: easy_install: command not found.

有什么问题?

pip 似乎已变成 python -m pip(在您的情况下,python3 -m pip,因为 Ubuntu 将 2.x 行保持为 python) 在 Python 3.4.

easy_install for Python 2.7 是 python-setuptools 包的一部分。安装后,运行 easy_install pip 将为您的 Python 2.7 安装使用安装 pip。

apt-get install python-pip怎么样?至少,Debian 官方存储库甚至有来自 wheezy 的 python-pip

遗憾的是,自 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

希望这对您有所帮助。