pip install urllib2失败的原因【转】

pip install  urllib2 提示找不到包:

 

Note

The urllib2 module has been split across several modules inPython 3 named urllib.request and urllib.error.The 2to3 tool will automatically adapt imports when convertingyour sources to Python 3.

 

 

Pyhton2中的urllib2工具包,在Python3中分拆成了urllib.request和urllib.error两个包。就导致找不到包,同时也没办法安装。

所以需要install urllib.request和install urllib.error 两个包,然后将import urllib2修改为import urllib.request 和import urllib.error。

同时代码中的方法函数也需要修改,基本就是将urllib2.xxx修改为urllib.request.xxx。

官方介绍:https://docs.python.org/2/library/urllib2.html

posted @ 2020-08-03 10:48  胖鲸  阅读(1522)  评论(0)    收藏  举报