Python 扭曲 twisted.internet
Python Twisted twisted.internet
我从 git
下载了 twisted
git clone -b t运行k https://github.com/twisted/twisted.git
正如http://twistedmatrix.com/trac/wiki/Downloads建议的那样。
然后我表演了
sudo python setup.py 安装
但现在当我 运行 一些 python 文件时,我得到
ImportError: 没有名为 twisted.internet.
的模块
我还注意到,在 git 的 README.rst 中,它没有提到模块 twisted.internet.
那么我应该从哪里得到它?
永远不要sudo pip install ...
任何事情。请改用 virtualenv。
exarkun@baryon:~$ virtualenv /tmp/virtualenv-demo
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/virtualenv-demo/bin/python2
Also creating executable in /tmp/virtualenv-demo/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
exarkun@baryon:~$ . /tmp/virtualenv-demo/bin/activate
(virtualenv-demo) exarkun@baryon:~$ pip install twisted
Collecting twisted
Collecting constantly>=15.1 (from twisted)
Using cached constantly-15.1.0-py2.py3-none-any.whl
Collecting zope.interface>=3.6.0 (from twisted)
Collecting Automat>=0.3.0 (from twisted)
Using cached Automat-0.5.0-py2.py3-none-any.whl
Collecting incremental>=16.10.1 (from twisted)
Using cached incremental-16.10.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /tmp/virtualenv-demo/lib/python2.7/site-packages (from zope.interface>=3.6.0->twisted)
Collecting attrs (from Automat>=0.3.0->twisted)
Using cached attrs-16.3.0-py2.py3-none-any.whl
Requirement already satisfied: six in /tmp/virtualenv-demo/lib/python2.7/site-packages (from Automat>=0.3.0->twisted)
Requirement already satisfied: appdirs>=1.4.0 in /tmp/virtualenv-demo/lib/python2.7/site-packages (from setuptools->zope.interface>=3.6.0->twisted)
Requirement already satisfied: packaging>=16.8 in /tmp/virtualenv-demo/lib/python2.7/site-packages (from setuptools->zope.interface>=3.6.0->twisted)
Requirement already satisfied: pyparsing in /tmp/virtualenv-demo/lib/python2.7/site-packages (from packaging>=16.8->setuptools->zope.interface>=3.6.0->twisted)
Installing collected packages: constantly, zope.interface, attrs, Automat, incremental, twisted
Successfully installed Automat-0.5.0 attrs-16.3.0 constantly-15.1.0 incremental-16.10.1 twisted-17.1.0 zope.interface-4.3.3
(virtualenv-demo) exarkun@baryon:~$ python -c 'import twisted.internet; print twisted.internet'
<module 'twisted.internet' from '/tmp/virtualenv-demo/local/lib/python2.7/site-packages/twisted/internet/__init__.pyc'>
(virtualenv-demo) exarkun@baryon:~$ deactivate
exarkun@baryon:~$
我从 git
下载了 twistedgit clone -b t运行k https://github.com/twisted/twisted.git
正如http://twistedmatrix.com/trac/wiki/Downloads建议的那样。
然后我表演了
sudo python setup.py 安装
但现在当我 运行 一些 python 文件时,我得到
ImportError: 没有名为 twisted.internet.
的模块我还注意到,在 git 的 README.rst 中,它没有提到模块 twisted.internet.
那么我应该从哪里得到它?
永远不要sudo pip install ...
任何事情。请改用 virtualenv。
exarkun@baryon:~$ virtualenv /tmp/virtualenv-demo
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/virtualenv-demo/bin/python2
Also creating executable in /tmp/virtualenv-demo/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
exarkun@baryon:~$ . /tmp/virtualenv-demo/bin/activate
(virtualenv-demo) exarkun@baryon:~$ pip install twisted
Collecting twisted
Collecting constantly>=15.1 (from twisted)
Using cached constantly-15.1.0-py2.py3-none-any.whl
Collecting zope.interface>=3.6.0 (from twisted)
Collecting Automat>=0.3.0 (from twisted)
Using cached Automat-0.5.0-py2.py3-none-any.whl
Collecting incremental>=16.10.1 (from twisted)
Using cached incremental-16.10.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /tmp/virtualenv-demo/lib/python2.7/site-packages (from zope.interface>=3.6.0->twisted)
Collecting attrs (from Automat>=0.3.0->twisted)
Using cached attrs-16.3.0-py2.py3-none-any.whl
Requirement already satisfied: six in /tmp/virtualenv-demo/lib/python2.7/site-packages (from Automat>=0.3.0->twisted)
Requirement already satisfied: appdirs>=1.4.0 in /tmp/virtualenv-demo/lib/python2.7/site-packages (from setuptools->zope.interface>=3.6.0->twisted)
Requirement already satisfied: packaging>=16.8 in /tmp/virtualenv-demo/lib/python2.7/site-packages (from setuptools->zope.interface>=3.6.0->twisted)
Requirement already satisfied: pyparsing in /tmp/virtualenv-demo/lib/python2.7/site-packages (from packaging>=16.8->setuptools->zope.interface>=3.6.0->twisted)
Installing collected packages: constantly, zope.interface, attrs, Automat, incremental, twisted
Successfully installed Automat-0.5.0 attrs-16.3.0 constantly-15.1.0 incremental-16.10.1 twisted-17.1.0 zope.interface-4.3.3
(virtualenv-demo) exarkun@baryon:~$ python -c 'import twisted.internet; print twisted.internet'
<module 'twisted.internet' from '/tmp/virtualenv-demo/local/lib/python2.7/site-packages/twisted/internet/__init__.pyc'>
(virtualenv-demo) exarkun@baryon:~$ deactivate
exarkun@baryon:~$