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)
为了确保,我检查了一下:
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)
然而,当我实际运行我的python程序时,它会出现错误:
import gevent
ImportError: No module named gevent
请告知。
我尝试过的东西:
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
以及这里提到的事情: https://github.com/PokeAlarm/PokeAlarm/issues/22
我还尝试卸载pip安装并执行apt-get:
sudo apt-get install python-gevent python-gevent-websocket
这里提到:https://askubuntu.com/questions/836029/importerror-no-module-named-gevent/1013457#1013457
答案 0 :(得分:1)
确保你的pip引用你正在使用的同一个python, 在许多系统上,您可以安装多个python版本。 你可以通过运行来查看你的pip属于哪个python:
pip --version
答案 1 :(得分:1)
在Ubuntu 16.04中的Python虚拟环境中工作我得到了以下结果:
$ 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
在我的Python虚拟环境中成功运行,但在运行以下命令之前,它在我的Python虚拟环境之外无效:
sudo apt install python-gevent # also works in all currently supported versions of Ubuntu
描述:gevent是一个基于协程的Python网络库。 gevent使用greenlet在libevent事件循环之上提供高级同步API。
答案 2 :(得分:1)
转到 anaconda navigator 并选择您正在工作的环境...然后选择未安装,检查 gevent 并安装