没有名为setuptools的模块


98

我想安装twilio的安装文件。通过给定命令安装它时,出现错误:

没有名为setuptools的模块。

您能告诉我该怎么办吗?

我在用 python 2.7

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Python27>python D:\test\twilio-twilio-python-26f6707\setup.py install
Traceback (most recent call last):
  File "D:\test\twilio-twilio-python-26f6707\setup.py", line 2, in <module>
    from setuptools import setup, find_packages
ImportError: No module named setuptools

1
...但是标题可以很容易地用谷歌搜索...而我最喜欢的答案是这个
Wolf

3
我投票支持重新打开,因为在Ubuntu 14.04上存在此问题,这不是由于安装程序的x86 / x64冲突。简而言之,我只需要安装pip-– sudo apt-get install python-pip
Eric

对于其他遇到相同问题的人,我遇到了这个问题:尝试为Azure walinuxagent运行setup.py脚本。
Alex Egli

Answers:


98

安装并重setuptools试。

尝试命令:

sudo apt-get install -y python-setuptools

4
我不赞成您不提供安装setuptools的命令,但是您确实需要转到该URL以了解如何在特定系统上安装它。

25
Debian / ubuntu:apt-get install -y python-setuptools
Daniele Vrut'1

1
当使用apt install --no-install-recommends ...
peter_v

46

对于ubuntu用户,由于未在系统范围内安装setuptool,因此可能会出现此错误。只需使用以下命令安装setuptool:

sudo apt-get install -y python-setuptools

对于python3:

sudo apt-get install -y python3-setuptools

之后,请使用

sudo python setup.py install

就这样。


19
对于Python 3,请使用sudo apt-get install -y python3-setuptools
CGFoX

我仍然收到“ ImportError:没有名为setuptools的模块”。我还打开了一个新的命令外壳。
Geoffrey Anderson

16

对于Python运行此命令

apt-get install -y python-setuptools

对于Python 3。

apt-get install -y python3-setuptools

14

PyPA推荐的用于安装和管理Python包的工具pippip包含在Python 3.4(PEP 453)中,但是对于较旧的版本,这是安装方法(在Windows上使用Python 3.3):

下载https://bootstrap.pypa.io/get-pip.py

>c:\Python33\python.exe get-pip.py
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...

用法示例:

>c:\Python33\Scripts\pip.exe install pymysql
Downloading/unpacking pymysql
Installing collected packages: pymysql
Successfully installed pymysql
Cleaning up...

在您的情况下,将是这样(似乎pip缓存独立于Python版本):

C:\Python27>python.exe \code\Python\get-pip.py
Requirement already up-to-date: pip in c:\python27\lib\site-packages
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |################################| 69kB 255kB/s
Installing collected packages: wheel
Successfully installed wheel-0.29.0

C:\Python27>cd Scripts

C:\Python27\Scripts>pip install twilio
Collecting twilio
  Using cached twilio-5.3.0.tar.gz
Collecting httplib2>=0.7 (from twilio)
  Using cached httplib2-0.9.2.tar.gz
Collecting six (from twilio)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting pytz (from twilio)
  Using cached pytz-2015.7-py2.py3-none-any.whl
Building wheels for collected packages: twilio, httplib2
  Running setup.py bdist_wheel for twilio ... done
  Stored in directory: C:\Users\Cees.Timmerman\AppData\Local\pip\Cache\wheels\e0\f2\a7\c57f6d153c440b93bd24c1243123f276dcacbf43cc43b7f906
  Running setup.py bdist_wheel for httplib2 ... done
  Stored in directory: C:\Users\Cees.Timmerman\AppData\Local\pip\Cache\wheels\e1\a3\05\e66aad1380335ee0a823c8f1b9006efa577236a24b3cb1eade
Successfully built twilio httplib2
Installing collected packages: httplib2, six, pytz, twilio
Successfully installed httplib2-0.9.2 pytz-2015.7 six-1.10.0 twilio-5.3.0

0

对于python3是:

sudo apt-get install -y python3-setuptools
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.