python爬取图片失败什么原因_python3下利用gevent模块爬取图片出错问题

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值