[Twisted-Python] Problems running Twisted

Phil Hunt phil.hunt at tech.mrc.ac.uk
Fri Feb 20 04:48:32 EST 2004

I'm trying to set up a (very simple) web server using Twisted.
I'm using this example from the documentation:

# teg1.py

from twisted.web import server, resource
from twisted.internet import reactor

class Simple(resource.Resource):
    isLeaf = True
    def render(self, request):
        return "<html>Hello, world!</html>"

site = server.Site(Simple())
reactor.listenTCP(8080, site)

I've stored this as <teg1.py>. When I run:

   $ python teg1.py

Python complains that it can't import twisted.web:

   Traceback (most recent call last):
     File "teg1.py", line 3, in ?
       from twisted.web import server, resource
   ImportError: No module named twisted.web

I've previously installed Twisted by running:

   $ python setup.py install

which I thought would install all the modules and put them correctly
in the PYTHONPATH (tell me if this isn't true).

Am I doing somethnig wrong? I feel I have missed something fundamental, but
don't know what. Should I rename my file to <teg1.rpy> or something? Do I
need to run at the command-line ``mktap'' instead of ``python''?

Phil Hunt, phil.hunt at tech.mrc.ac.uk

More information about the Twisted-Python mailing list