首页 新闻 赞助 找找看

python3下利用gevent模块爬取图片出错问题

1
悬赏园豆:200 [已关闭问题] 关闭于 2018-12-10 14:10

from gevent import monkey
monkey.patch_all()
import urllib
import gevent

def downloader(img_name, img_url):
req = urllib.urlopen(img_url)
img_content = req.read()
with open(img_name, "wb") as f:
f.write(img_content)

def main():
gevent.joinall([gevent.spawn(downloader, "1.jpg", "https://cs-
op.douyucdn.cn/dycatr/game_cate/76a6d8b20e6c1a465c6f1bbedc35fd41.jpg"), ])

if name == "main":
main()
这串代码代码在python2下不会有问题,但在python3.5.2下运行显示monkey.patch_all 模块有问题,希望哥们解解惑,实在在网上查不到,也是初学python者,万分感激。以下是错误代码:
monkey.patch_all()
File "/usr/local/lib/python3.5/dist-packages/gevent/monkey.py", line 966, in patch_all
_notify_patch(events.GeventWillPatchAllEvent(modules_to_patch, kwargs), _warnings)

File "/usr/local/lib/python3.5/dist-packages/gevent/monkey.py", line 168, in _notify_patch
notify_and_call_entry_points(event)

File "/usr/local/lib/python3.5/dist-packages/gevent/events.py", line 112, in notify_and_call_entry_points
subscriber = plugin.load()

File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 2345, in load
self.require(*args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 2368, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)

File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 784, in resolve
raise DistributionNotFound(req, requirers)

pkg_resources.DistributionNotFound: The 'psutil; platform_python_implementation == "CPython" or sys_platform != "win32" and extra == "test"' distribution was not found and is required by the application

Demonsafe的主页 Demonsafe | 菜鸟二级 | 园豆:202
提问于:2018-12-10 11:16
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册