2017-03-20 3 views
0

J'ai téléchargé tordu de gitPython Twisted twisted.internet

du tronc de clone git https://github.com/twisted/twisted.git

comme http://twistedmatrix.com/trac/wiki/Downloads suggère.

Et puis je fis

sudo python setup.py install

Mais maintenant, quand je lance quelques fichiers python je reçois

ImportError: Aucun module nommé twisted.internet.

J'ai aussi remarqué, dans le README.rst de git, qu'il ne mentionne pas le module twisted.internet.

Alors, où dois-je l'obtenir?

+0

Avez-vous essayé 'pip install Twisted'? –

Répondre

1

Ne jamais sudo pip install ... quoi que ce soit. Utilisez virtualenv à la place.

[email protected]:~$ 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. 
[email protected]:~$ . /tmp/virtualenv-demo/bin/activate 
(virtualenv-demo) [email protected]:~$ 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) [email protected]:~$ 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) [email protected]:~$ deactivate 
[email protected]:~$ 
+0

merci pour votre aide. Mais quand je tape la commande python -c 'import twisted.internet; impression twisted.internet ', je reçois Fichier "", ligne 1 import twisted.internet; SyntaxeError: syntaxe invalide – lmbcerqueira

+1

Peut-être que vous utilisez Python 3 et que vous devez utiliser print en tant que fonction au lieu d'une instruction. La ligne 'python -c ...' était juste une démonstration que Twisted était correctement installé. Vous n'avez pas à faire ce pas. Vous pouvez simplement essayer d'exécuter n'importe quel code basé sur Twisted (en veillant à utiliser l'exécutable Python de virtualenv - il sera dans votre $ PATH donc ça devrait marcher - il ne faut pas coder en dur/usr/bin/python ou quelque chose comme ça n'importe où). –