gevent库:“导入错误:没有名为greenlet的模块”

时间:2022-06-05 18:10:16

hello guys I have downloaded a script that require gevent python library and every time I run the script it says :

大家好,我下载了一个需要gevent python库的脚本,每次运行这个脚本,它都会说:

 File "shodan.py", line 7, in <module>
   from gevent import monkey
 File "C:\Python27\lib\site-packages\gevent\__init__.py", line 48, in <module>
   from gevent.greenlet import Greenlet, joinall, killall
 File "C:\Python27\lib\site-packages\gevent\greenlet.py", line 6, in <module>
   from gevent.hub import greenlet, getcurrent, get_hub, GreenletExit, Waiter
 File "C:\Python27\lib\site-packages\gevent\hub.py", line 30, in <module>
   greenlet = __import__('greenlet').greenlet    
ImportError: No module named greenlet

I have successfully downloaded and installed gevent and i'm just confused can someone give me the solution and explain the problem.

我已经成功下载并安装了gevent,只是不知道是否有人能给我解决方案并解释这个问题。

4 个解决方案

#1


10  

Try to install greenlet via pip like so: pip install greenlet.

尝试通过pip来安装greenlet: pip安装greenlet。

#2


1  

This is how I do it to make it work:

我就是这样做的:

  1. Download the latest gevent source from github: gevent
  2. 从github下载最新的gevent源:gevent。
  3. replace the source code in C:\Python27\lib\site-packages\gevent\ with the download source code.
  4. 用下载的源代码替换C:\Python27\lib\site-packages\gevent\的源代码。

#3


0  

while running the command

在运行命令

python app.py

python app.py

instead try

而不是尝试

python2.7 app.py

python2.7 app.py

worked for me ....

为我工作....

#4


0  

Assuming you have gevent installed:

假设您安装了gevent:

Check that you don't have another file in the same folder named as gevent.py, because if yes then when you do "import gevent" it's importing/calling that file that you named gevent.py.

检查您没有在与gevent相同的文件夹中有另一个文件。py,因为如果是,当你做"导入gevent"时它会导入/调用那个你命名为gevent.py的文件。

Change the filename and it should work.

更改文件名,它应该可以工作。

#1


10  

Try to install greenlet via pip like so: pip install greenlet.

尝试通过pip来安装greenlet: pip安装greenlet。

#2


1  

This is how I do it to make it work:

我就是这样做的:

  1. Download the latest gevent source from github: gevent
  2. 从github下载最新的gevent源:gevent。
  3. replace the source code in C:\Python27\lib\site-packages\gevent\ with the download source code.
  4. 用下载的源代码替换C:\Python27\lib\site-packages\gevent\的源代码。

#3


0  

while running the command

在运行命令

python app.py

python app.py

instead try

而不是尝试

python2.7 app.py

python2.7 app.py

worked for me ....

为我工作....

#4


0  

Assuming you have gevent installed:

假设您安装了gevent:

Check that you don't have another file in the same folder named as gevent.py, because if yes then when you do "import gevent" it's importing/calling that file that you named gevent.py.

检查您没有在与gevent相同的文件夹中有另一个文件。py,因为如果是,当你做"导入gevent"时它会导入/调用那个你命名为gevent.py的文件。

Change the filename and it should work.

更改文件名,它应该可以工作。