DJ_Stuffy_K
DJ_Stuffy_K

Reputation: 635

no module named gevent even though it is installed

OS : Ubuntu 16.04 Python 2.7

pip list | grep gev
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
gevent (1.3a2)

Just to make sure, I checked:

  pip install --upgrade gevent
Requirement already up-to-date: gevent in /home/user/.local/lib/python2.7/site-packages
Requirement already up-to-date: greenlet>=0.4.13; platform_python_implementation == "CPython" in /home/user/.local/lib/python2.7/site-packages (from gevent)

However when I actually run my python program it bails out with an error:

 import gevent
ImportError: No module named gevent

Please advise.

Stuff I already tried:

pip --version
pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)


python -m pip install --user gevent
Requirement already satisfied: gevent in /home/user/.local/lib/python2.7/site-packages
Requirement already satisfied: greenlet>=0.4.13; platform_python_implementation == "CPython" in /home/user/.local/lib/python2.7/site-packages (from gevent)

which -a python
/usr/bin/python
/usr/bin/python

along with things mentioned here: https://github.com/PokeAlarm/PokeAlarm/issues/22

I also tried uninstalling the pip installation and doing apt-get :

sudo apt-get install python-gevent python-gevent-websocket

mentioned here: https://askubuntu.com/questions/836029/importerror-no-module-named-gevent/1013457#1013457

Upvotes: 6

Views: 48477

Answers (4)

mukesh
mukesh

Reputation: 1

Delete gevent library by browsing through Lib/site-packages

Try the install command pip install gevent

Upvotes: 0

karel
karel

Reputation: 5862

Working in a Python virtual environment in Ubuntu 16.04 I got the following results:

$ python -m pip install gevent 
Requirement already satisfied: gevent in ./lib/python2.7/site-packages  
Requirement already satisfied: greenlet>=0.4.10 in ./lib/python2.7/site-packages (from gevent)

import gevent worked successfully in my Python virtual environment, but it did not work outside of my Python virtual environment until I ran the following command:

sudo apt install python-gevent # also works in all currently supported versions of Ubuntu 

Description: gevent is a coroutine-based Python networking library. gevent uses greenlet to provide a high-level synchronous API on top of libevent event loop.

You can also install python3-gevent for Python 3.x in all currently supported versions of Ubuntu by running the following command:

sudo apt install python3-gevent

Upvotes: 8

Anita
Anita

Reputation: 11

enter image description here

goto anaconda navigator and select the environment on which you are working ...then select not installed ,check for gevent and install

Upvotes: 1

h24
h24

Reputation: 41

make sure that your pip references the same python that you are using, on many systems you can have multiple python versions installed. you can see which to which python your pip belongs by running:

pip --version

Upvotes: 4

Related Questions