Forums

ImportError: No module named socketio

Hello! I am new with Flask and the web applications in general. I am trying to deploy a Flask application that I found in a tutorial (http://dev.hasenj.org/post/38188152502/adding-web-sockets-to-flask-apps) but I get the next error (the application works ok in local):

"ImportError: No module named 'gevent'"

From the console I successfully installed gevent-socketio with the command "pip install --user gevent-socketio" but still the import is not working. I am using python 3.3 and Flask 0.10.1.

The line from the error is:

"from gevent import monkey"

Any idea? Thanks!

PD: Sorry I made a mistake in the title and now I can't change it, the error is "ImportError: No module named 'gevent'" but I think the problem is the same.

Complete log error:

2013-12-09 19:47:38,676 :Traceback (most recent call last):
2013-12-09 19:47:38,676 : File "/bin/user_wsgi_wrapper.py", line 67, in call
2013-12-09 19:47:38,676 : self.error_log_file.logger.exception("Error running WSGI application")
2013-12-09 19:47:38,677 : File "/usr/lib/python3.3/logging/init.py", line 1269, in exception
2013-12-09 19:47:38,677 : self.error(msg, args, kwargs)
2013-12-09 19:47:38,678 : File "/usr/lib/python3.3/logging/init.py", line 1262, in error
2013-12-09 19:47:38,678 : self._log(ERROR, msg, args,
kwargs)
2013-12-09 19:47:38,679 : File "/usr/lib/python3.3/logging/init.py", line 1368, in _log
2013-12-09 19:47:38,680 : self.handle(record)
2013-12-09 19:47:38,680 : File "/usr/lib/python3.3/logging/init.py", line 1377, in handle
2013-12-09 19:47:38,681 : if (not self.disabled) and self.filter(record):
2013-12-09 19:47:38,681 : File "/usr/lib/python3.3/logging/init.py", line 687, in filter
2013-12-09 19:47:38,681 : for f in self.filters:
2013-12-09 19:47:38,682 : File "/bin/user_wsgi_wrapper.py", line 59, in call
2013-12-09 19:47:38,682 : app_iterator = self.app(environ, start_response)
2013-12-09 19:47:38,682 : File "/bin/user_wsgi_wrapper.py", line 73, in import_error_application
2013-12-09 19:47:38,682 : raise e
2013-12-09 19:47:38,682 : File "/bin/user_wsgi_wrapper.py", line 67, in call
2013-12-09 19:47:38,683 : self.error_log_file.logger.exception("Error running WSGI application")
2013-12-09 19:47:38,683 : File "/usr/lib/python3.3/logging/init.py", line 1269, in exception
2013-12-09 19:47:38,684 : self.error(msg,
args, kwargs)
2013-12-09 19:47:38,684 : File "/usr/lib/python3.3/logging/init.py", line 1262, in error
2013-12-09 19:47:38,685 : self._log(ERROR, msg, args,
kwargs)
2013-12-09 19:47:38,685 : File "/usr/lib/python3.3/logging/init.py", line 1368, in _log
2013-12-09 19:47:38,686 : self.handle(record)
2013-12-09 19:47:38,686 : File "/usr/lib/python3.3/logging/init.py", line 1377, in handle
2013-12-09 19:47:38,687 : if (not self.disabled) and self.filter(record):
2013-12-09 19:47:38,687 : File "/usr/lib/python3.3/logging/init.py", line 687, in filter
2013-12-09 19:47:38,688 : for f in self.filters:
2013-12-09 19:47:38,688 : File "/bin/user_wsgi_wrapper.py", line 59, in call
2013-12-09 19:47:38,688 : app_iterator = self.app(environ, start_response)
2013-12-09 19:47:38,688 : File "/bin/user_wsgi_wrapper.py", line 73, in import_error_application
2013-12-09 19:47:38,689 : raise e
2013-12-09 19:47:38,689 : File "/bin/user_wsgi_wrapper.py", line 82, in <module>
2013-12-09 19:47:38,689 : application = load_wsgi_application()
2013-12-09 19:47:38,689 : File "/bin/user_wsgi_wrapper.py", line 78, in load_wsgi_application
2013-12-09 19:47:38,689 : return import(os.environ['WSGI_MODULE'], globals(), locals(), ['application']).application
2013-12-09 19:47:38,690 : File "/var/www/okapi_pythonanywhere_com_wsgi.py", line 16, in <module>
2013-12-09 19:47:38,690 : from main import app as application
2013-12-09 19:47:38,691 : File "/home/okapi/mysite/main.py", line 4, in <module>
2013-12-09 19:47:38,692 : from gevent import monkey
2013-12-09 19:47:38,692 :ImportError: No module named 'gevent'

  • Are you sure that gevent installed correctly?
  • Can you open a Python3.3 console and import gevent?

If not, take a look at this SO problem and then request that the PA Staff install your module for you...☺

~a2j

Thanks for your response! I only can import gevent if I open a python 2.7 console but if I want to install Flask 0.10.1 I have to choose python 3.3, that seems to be the problem.

How can I install gevent with python 3.3? I will take a look to your link

I tried with pip-3.3 but did not work.

I installed the previous version of Flask with python 2.7. Now I get the error "ImportError: No module named socketio" but in the console I can type with no errors import socketio :S

Ups, I forgot to reaload, I think is working now...

Super!! Welcome to PA!!

~a2j

Great, glad it's working :-)

@okapi: I hope everything is still looking good for you. The community is here if needed.