Gevent: No such module `pywsgi`

Created on 3 Oct 2016  路  3Comments  路  Source: gevent/gevent

  • gevent version: 1.1.2
  • Python version: 2.7.12
  • Operating System: Windows 10 x64

    Description:

After installing gevent via pip install gevent, I cannot import gevent.pywsgi

What I've run:

pip install gevent

gevent.py:

from gevent.pywsgi import WSGIServer
from app import app

http_server = WSGIServer(('', 8080), app)
http_server.serve_forever()

Hopefully this is enough to reproduce. If not I can include the project I'm attempting to use gevent with

> python gevent.py
Traceback (most recent call last):
  File "gevent.py", line 1, in <module>
    from gevent.pywsgi import WSGIServer
  File "G:\Git\statistics-viewer\gevent.py", line 1, in <module>
    from gevent.pywsgi import WSGIServer
ImportError: No module named pywsgi
not gevent Question

Most helpful comment

If your script is named gevent.py, you're going to have a conflict with the gevent _package_. Try naming your script something else.

Python 3 produces a cleaner error message:

$ echo 'import gevent.pywsgi' >> gevent.py
$ python gevent.py
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "gevent.py", line 1, in <module>
    import gevent.pywsgi
  File "gevent.py", line 1, in <module>
    import gevent.pywsgi
ImportError: No module named 'gevent.pywsgi'; 'gevent' is not a package

Renaming the script solves the problem:

$ mv gevent.py myscript.py
$ python myscript.py
$

All 3 comments

If your script is named gevent.py, you're going to have a conflict with the gevent _package_. Try naming your script something else.

Python 3 produces a cleaner error message:

$ echo 'import gevent.pywsgi' >> gevent.py
$ python gevent.py
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "gevent.py", line 1, in <module>
    import gevent.pywsgi
  File "gevent.py", line 1, in <module>
    import gevent.pywsgi
ImportError: No module named 'gevent.pywsgi'; 'gevent' is not a package

Renaming the script solves the problem:

$ mv gevent.py myscript.py
$ python myscript.py
$

I have this same issue in Windows 10 professional x64, python 2.7.13
Running a basic test in OSX via CLI, (opening python interpreter in terminal, import gevent.pywsgi) did not throw any errors.

Are there any Unix/POSIX specific dependencies that you would expect may have a hard time in the windows environment?

wsgi_class_error

Thanks,

When you say "this same issue" do you mean the same ImportError: ImportError: No module named 'gevent.pywsgi'; 'gevent' is not a package (or ImportError: No module named pywsgi on Python 2)? If so the probable cause is the same (a gevent.py somewhere on your sys.path).

There should be no Unix-specific dependencies. pywsgi is tested on Windows with the same test suite as other platforms.

Was this page helpful?
0 / 5 - 0 ratings