没有名为setuptools的模块
我想安装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
7 个回答
2
对于Python3来说是:
sudo apt-get install -y python3-setuptools
15
安装和管理Python包的工具,PyPA推荐使用的是pip
。pip
从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
18
要在Python中运行这个命令
apt-get install -y python-setuptools
这是针对Python 3的。
apt-get install -y python3-setuptools
55
对于Ubuntu用户来说,这个错误可能是因为系统没有全局安装setuptool。只需要使用下面的命令来安装setuptool:
sudo apt-get install -y python-setuptools
如果你使用的是python3:
sudo apt-get install -y python3-setuptools
然后再正常安装你的包,使用下面的命令:
sudo python setup.py install
就这么简单。
119