ImportError: no modules named 'twisted'

I am new to python and I am writing a simple TCP server Server.py and I am trying to import a reactor using this line of code from twisted.internet import reactor The problem is that when I run the code I get this error

 /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/Nora/PycharmProjects/Server/Server.py Traceback (most recent call last): File "/Users/Nora/PycharmProjects/Server/Server.py", line 2, in <module> from twisted.internet import reactor ImportError: No module named 'twisted' 

Please note that I am using OS X Yosemite and I have installed a new version of python 3.5, how can I get back to the system built into the version that is already twisted?

+5
source share
1 answer

As xiaohen commented, twisted is not part of the python standard library (it is installed on the OS X internal icon on Apple, but it will not be automatically available if you install a newer version of python).

pip install twisted will most likely lead you there.

By the way, you might want to read and install the python virtualenv system before installing twisted so that you know you can flush with your python libraries without worrying about corrupting your main python load (such as http://www.dabapps.com / blog / introduction-to-pip-and-virtualenv-python / or http://michaelheap.com/virtualenv-and-pip-a-python-environment-in-60-seconds/ will help)

+4
source

Source: https://habr.com/ru/post/1234178/


All Articles