I try to install module urllib2 for python 2.7 (I as usual use command pip install), but have an error
No matching distribution found for urllib2..
What should I do?
The Python "ModuleNotFoundError: No module named 'urllib2'" occurs because the urllib2 module has been split into urllib. request and urllib. response in Python 3. To solve the error, import the module as from urllib.
urllib. request is part of the standard library and does not need installing.
Simple urllib2 scriptimport urllib2 response = urllib2. urlopen('http://python.org/') print "Response:", response # Get the URL. This gets the real URL. print "The URL is: ", response.
You don't need to pip install urllib/urllib2
In Python 2.7 , urllib and urllib2 comes with python .
import urllib
OR
import urllib2
In Python 3+ , urllib2 is replaced with urllib.request.
import urllib.request as urllib2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With