This project has moved and is read-only. For the latest updates, please go here.


Gevent Fails to Import in PTVS 2.1 Beta


VS 2010 with PTVS 2.1 Beta and Python 2.7.

I get an "ImportError: No module named greenlet" when I execute my Flask Web Project. The error is related to the "import greenlet" statement in gevent's I've installed and reinstalled both gevent and greenlet in several locations: Python27\Lib\site-packages, Python27\Lib, and in the Python Environments "env\Lib" folder associated with the project. Moving out of gevent folder resolves the issue in, but then the error occurs in's "from gevent.hub import greenlet..."

Notably, I do not have any issues with the same import statement ("import gevent") in IDLE.

Any help or suggestions are greatly appreciated.
Closed Aug 5, 2014 at 12:20 AM by Zooba


Zooba wrote May 16, 2014 at 7:41 PM

I haven't checked out gevent/greenlet's install procedure. Do you know if it modifies your global PYTHONPATH variable? What does its folder structure look like when you install it?

aaapurdy wrote May 19, 2014 at 2:54 PM

Zooba -

gevent and greenlet are both available via easy_install, but they can be installed manually also. I'm new to both these modules, but the only apparent dependency between gevent and greenlet is I do not think either install modified the PYTHONPATH. I tried manually appending the path to gevent's folder, but this also did not resolve the problem in VS 2010 (still works in IDLE).

The folder structure is identical to what's on GitHub ( within my Python\Lib\gevent path.

aaapurdy wrote May 19, 2014 at 4:34 PM

Some additional information that may be helpful...

"import gevent" works in the Python Interactive window and also when using VS 2010 with a Python Application project. The issues seems to be isolated to the Flask Web Project. Perhaps related to the virtual environment?

Zooba wrote May 19, 2014 at 4:50 PM

Ah, you're using a virtual environment.

You will definitely need gevent installed into the virtual environment, unless you've manually created it to inherit packages from the global Python (this is disabled by default because it rather defeats the purpose).

In 2.1 Beta you should be able to right-click your virtual environment and open an Interactive window specifically for that (or maybe you need to go through the Environments List window, but I think beta has the context menu). If the import works from here and not when running, then Flask must be doing something strange.

Hopefully (because it's the easiest to fix), importing gevent in the virtual environment's interactive window will fail and give a helpful error message.

aaapurdy wrote May 19, 2014 at 6:11 PM

Zooba - thank you again for your help. This time I installed greenlet then gevent using PIP directly into the virtual environment. It is now running correctly.