90abyss
90abyss

Reputation: 7337

Python Tornado: ImportError: No module named 'tornado'

This is my tornado file::

from tornado.wsgi import WSGIContainer
from tornado.ioloop import IOLoop
from tornado.web import FallbackHandler, RequestHandler, Application
from flasky import app

class MainHandler(RequestHandler):
  def get(self):
    self.write("This message comes from Tornado ^_^")

tr = WSGIContainer(app)

application = Application([
(r"/tornado", MainHandler),
(r".*", FallbackHandler, dict(fallback=tr)),
])

if __name__ == "__main__":
  application.listen(5000)
  IOLoop.instance().start()

Basically I'm running a flask server in Tornado. But I'm getting this error:

from tornado.wsgi import WSGIContainer 
ImportError: No module named 'tornado'

I've already gone through this post: Python Tornado: WSGI module missing?

But my file is not named Tornado.py so that doesn't apply to me.

Please help.

Upvotes: 13

Views: 61539

Answers (4)

Ketan Mahajan
Ketan Mahajan

Reputation: 63

I faced the issue while testing tornado for the first time. It was because I named the file as tornado.py (as also mentioned by Mohamed Abdelijelil). I renamed it to tornado_test.py and it worked.

Upvotes: 5

Sandeep Goswami
Sandeep Goswami

Reputation: 79

I got rid of this by using following command.

sudo python3 -m pip install tornado

Upvotes: 7

A. Jesse Jiryu Davis
A. Jesse Jiryu Davis

Reputation: 24009

A common problem is having multiple Python interpreters, or multiple Python environments, installed. "pip" and "python" may use different environments. Try installing Tornado like this:

python -m pip install tornado

Upvotes: 16

Mohamed Abdeljelil
Mohamed Abdeljelil

Reputation: 149

check if tornado module is installed with pip and if you are using a virtualenv check if it's activated

Upvotes: 0

Related Questions