python gevent异常:MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors
异常:
python gevent魔法补丁出现错误提示:MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError
原因:
import包名顺序导入错误,使用gevent,务必将import gevent,from gevent import monkey,monkey.patch_all()三行语句放在其他所有的import语句之前
例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
don16@don16-VirtualBox:~$ python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> import gevent >>> from gevent import monkey >>> monkey.patch_all() __main__:1: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016 True >>> quit() don16@don16-VirtualBox:~$ python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gevent >>> from gevent import monkey >>> monkey.patch_all() True >>> import requests >>> |