Sam
Sam

Reputation: 129

Getting started with Twisted in Python in Eclipse

I am trying to learn how to use twisted to make a simple server. I have installed twisted and it is for Python 2.7 which is the version of pyhon I am using. I am also using eclipse to run these programs.
I have followed the instructions on this tutorial:

Running a Twisted Application in PyDev

But still run into this error when running this program.

from twistd.internet import reactor
reactor.run()

Traceback (most recent call last):
  File "M:\Java\Twisted Stuff\src\test_server.py", line 7, in <module>
    from twisted.internet import reactor
  File "M:\Java\Twisted Stuff\src\twisted.py", line 13, in <module>
ImportError: No module named scripts.twistd

I have double checked all my main module and arguments from the tutorial to make sure they apply. but I still run into this error.
Thank you very much in advance.

When I downloaded twisted the file is named twistd.py so I tried both with and without the 'e' in twisted and neither have worked. My file is named test_server.py it is not trying to import myself.

Upvotes: 0

Views: 875

Answers (3)

Sam
Sam

Reputation: 129

The problem was I needed to install the zope interface as well. Once i got that installed i continued to have problems but i just needed to create a reactor object and then it worked.

Upvotes: 0

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115520

Your first line should be:

from twisted.internet import reactor
          ^
          |
          |--- note the missing "e" in twisted 

Upvotes: 0

Liquid_Fire
Liquid_Fire

Reputation: 7048

It looks like you've named your own file twisted.py. This is a bad idea, as it means that when you try import twisted (or a variation), it will load your file rather than the actual library.

To avoid this, name your file something else, and fix the twistd/twisted typo.

Upvotes: 4

Related Questions