【问题标题】:pip, easy_install commands not working in Ubuntu. Python 2.7 and 3.4 are installedpip、easy_install 命令在 Ubuntu 中不起作用。已安装 Python 2.7 和 3.4
【发布时间】:2015-03-31 16:43:17
【问题描述】:

我对 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,如stackoverflow 上的另一个问题所述。但这会产生错误sudo: easy_install: command not found

有什么问题?

【问题讨论】:

  • 先试试sudo apt-get install python-setuptools
  • @ceejayoz 这行得通。现在我有了easy_install 和pip。但是你为什么认为 pip 一开始就不存在呢?它不应该出现在 python 3.4 中吗?
  • 你确定你使用的是 Python 3.4 吗?如果你做python --version,它会显示什么?
  • docs.python.org/3/installing 说你会在 3.4 中使用 python -m pip install SomePackage 而不是 pip install SomePackage,顺便说一句。
  • python --version 显示 Python 2.7.6python3 --version 显示 Python 3.4.0

标签: python-2.7 python-3.x pip python-3.4 easy-install


【解决方案1】:

很遗憾,根据 Matthias 的更新,自 2018 年 4 月起,python-setuptools 不再附带easy_install

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_instlall一起提供,但是那里有很多教程/答案说它会起作用。这为我节省了很多时间。谢谢!
  • 随时,兄弟。
【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

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

    【讨论】:

    • 是的。你是对的。当我尝试运行python3 -m pip 时,我得到/usr/local/bin: No module named pip。那么如何获得 python 3.4 的 pip 呢?
    • @ak31 stackoverflow.com/questions/24137291/… 好像是同样的问题,有解决办法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-08
    • 2021-06-22
    • 1970-01-01
    • 2014-09-13
    • 2018-04-08
    • 1970-01-01
    相关资源
    最近更新 更多