Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Tornado: ImportError: No module named 'tornado'

Tags:

python

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.

like image 850
90abyss Avatar asked Jan 27 '16 22:01

90abyss


3 Answers

I got rid of this by using following command.

sudo python3 -m pip install tornado
like image 114
Sandeep Goswami Avatar answered Nov 15 '22 17:11

Sandeep Goswami


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
like image 31
A. Jesse Jiryu Davis Avatar answered Nov 15 '22 18:11

A. Jesse Jiryu Davis


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.

like image 27
Ketan Mahajan Avatar answered Nov 15 '22 18:11

Ketan Mahajan