Search code examples
pythonflasktornado

Python Tornado: WSGI module missing?


I did a pip install tornado but I cannot run the following code because WSGI module is missing??

http://flask.pocoo.org/docs/deploying/wsgi-standalone/

from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from myapp import app

http_server = HTTPServer(WSGIContainer(app))
http_server.listen(5000)
IOLoop.instance().start()

Solution

  • If your file is named tornado.py, it will try to import things from that file instead of the directory on site-packages. This is probably the most common source of "no module named X" ImportErrors. Rename the file and it should work.

    After you rename the file from tornado.py to something else, also delete the tornado.pyc that got created.