__init__() got an unexpected keyword argument 'timeout'- URLlib2

2k views Asked by At

I don't know what happened, today suddenly pip stopped working. When I tried to install anything with pip or easy install I get the timeout error.

Please find the below track trace for urllib2 when used from command prompt.

>>> import urllib2
>>> f = urllib2.urlopen('http://www.python.org/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 400, in open
    response = self._open(req, data)
  File "C:\Python27\lib\urllib2.py", line 418, in _open
    '_open', req)
  File "C:\Python27\lib\urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python27\lib\urllib2.py", line 1146, in do_open
    h = http_class(host, timeout=req.timeout) # will parse host:port
TypeError: __init__() got an unexpected keyword argument 'timeout'

Is my URLlib2 corrupted? How can I fix this?

1

There are 1 answers

0
Karthick On

There was a problem with version of urllib2 I was using. Uninstalled python completely(You might need to remove\rename the default python27 folder) to re-install it fresh.

Note: Issue will not be resolved If you re-install on the same location where your site-packages already exists.