【问题标题】:Python can't find setuptoolsPython 找不到安装工具
【发布时间】:2016-10-07 22:48:03
【问题描述】:

我在尝试 setup.py 安装包时收到以下 ImportError:

Traceback (most recent call last):
   File "setup.py", line 4, in <module>
    from setuptools import setup, Extension
ImportError: No module named setuptools

虽然已经安装了 setuptools,但还是会发生这种情况:

amir@amir-debian:~$ sudo apt-get install python-setuptools
[sudo] password for amir: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-setuptools is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

为什么python找不到setuptools模块?

【问题讨论】:

标签: python python-2.7 setuptools


【解决方案1】:

您的系统上可能安装了多个 python 版本。例如,如果您从源代码安装了 python,然后再次使用 apt-get。 Apt-get 将安装到默认的 python 版本。确保你是一致的。

可能使用 pip install setuptools 可以解决您的问题。

试试这些命令:

$which python
/usr/bin/python
$python --version
Python 2.7.12

确保输出符合您的期望。

按照这个答案的建议,删除以前的安装并重新开始可能是值得的:

Python 3: ImportError "No Module named Setuptools"

【讨论】:

  • 我最近从源代码安装了python2.7.12。我应该将它指向我系统(2.7.3)上旧版本的 dist-packages 吗?我怎样才能保持一致?
  • Apt-get 是一个 debian 的包管理器。据推测,如果您通过“apt-get install python”安装了 python,它就会起作用。最好的办法是使用安装在高于 2.7.9 的版本上的 python 包管理器,称为“pip”。命令是:pip install setuptools
  • 我试过pip,但是setuptools已经是newset版本了:Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/dist-packages
猜你喜欢
  • 2011-04-08
  • 1970-01-01
  • 1970-01-01
  • 2011-05-05
  • 2014-01-17
  • 1970-01-01
  • 2022-01-05
  • 2014-08-10
  • 2014-01-14
相关资源
最近更新 更多