Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install urllib2 for python 2.7

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?

like image 588
Anna Timko Avatar asked Jan 14 '17 13:01

Anna Timko


People also ask

How do I fix No module named urllib2?

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.

Do you need to install Urllib?

urllib. request is part of the standard library and does not need installing.

How do I import urllib2 in Python 3?

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.


1 Answers

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 
like image 117
Vidya Sagar Avatar answered Oct 13 '22 05:10

Vidya Sagar