Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot import wsgi from gevent

Tags:

python

heroku

I am trying to run my heroku app locally so that I work on it when I don't have internet. I am able to run the app completely fine on the Heroku website after pushing it however I can't run it locally. When I run heroku local I get this error in particular:

11:17:19 web.1   |  Traceback (most recent call last):
11:17:19 web.1   |    File "app.py", line 24, in <module>
11:17:19 web.1   |      bottle.run(server='gevent', host='0.0.0.0', port=os.environ.get('PORT', 5000))
11:17:19 web.1   |    File "/usr/local/lib/python2.7/site-packages/bottle.py", line 3127, in run
11:17:19 web.1   |      server.run(app)
11:17:19 web.1   |    File "/usr/local/lib/python2.7/site-packages/bottle.py", line 2907, in run
11:17:19 web.1   |      from gevent import wsgi, pywsgi, local
11:17:19 web.1   |  ImportError: cannot import name wsgi
11:17:19 web.1   Exited with exit code 1

Please note I have downloaded gevent using pip install gevent
Also I am on a mac version 10.13.5 in case that is relavent
Thanks

like image 781
Mathew Avatar asked Jun 17 '18 21:06

Mathew


1 Answers

gevent.wsgi was deprecated for years and was finally removed in gevent 1.3. There's an open bottle bug for this problem. Some of your options are:

  1. Use a different WSGI server. You can directly use gevents wsgi server with python -m gevent.pywsgi my_module:my_app. Or try gunicorn
  2. Downgrade to an older gevent
  3. Patch the bottle sources to not have the broken import. gevent.wsgi simply did from gevent.pywsgi import *, so anywhere you see wsgi.Thing just replace it with pywsgi.Thing.
like image 150
Jason Madden Avatar answered Sep 29 '22 10:09

Jason Madden