即使已安装,也没有名为gevent的模块
OS:Ubuntu 16.04 Python 2.7
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)
但是,当我实际运行python程序时,它因出现错误而失败:
However when I actually run my python program it bails out with an error:
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
along with things mentioned here: https://github.com/PokeAlarm/PokeAlarm/issues/22
我还尝试卸载pip安装并执行apt-get:
I also tried uninstalling the pip installation and doing apt-get :
sudo apt-get install python-gevent python-gevent-websocket
在这里提到: https://askubuntu.com/questions/836029/importerror-no-module-named-gevent/1013457#1013457
在Ubuntu 16.04中的Python虚拟环境中工作,我得到了以下结果:
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
在我的Python虚拟环境中可以成功运行,但是在我运行以下命令之前,它不能在我的Python虚拟环境中运行:
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
描述:gevent是一个基于协程的Python网络库. gevent使用greenlet在libevent事件循环的顶部提供了高级同步API.
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.