I've got a problem which is this:
Sorry
Traceback (most recent call last):
File "testconn.py", line 2, in <module>
import httplib
File "C:\Python27\lib\httplib.py", line 680, in <module>
class HTTPConnection:
File "C:\Python27\lib\httplib.py", line 692, in HTTPConnection
timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
AttributeError: 'module' object has no attribute '_GLOBAL_DEFAULT_TIMEOUT'
I seriously didn't have this issue like 3 days ago, everything was working fine and now this. Here's my code: (To mention that I tried adding timeout, I tried following the strict syntax of urlopen (Adding timeout aswell). Nothing seemed to do it.)
import httplib
import urllib2
headers = {"pragma" : "no-cache"}
req = urllib2.Request("http://google.com/", headers = header)
response=urllib2.urlopen(req)
print response
I'd appreciate any help.
Check if you have your own socket.py
file. That shadows import of standard library socket
module.
Find it, rename(or remove) it. You should also rename(or remove) socket.pyc
.
BTW, the following line has a typo ( header s )
req = urllib2.Request("http://google.com/", headers = header)
# ^
Also if you're importing Flask
in socket.py
file, you should change file name to something else.
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