I am trying to call urllib2 simple code.
import urllib2
f = urllib2.urlopen('http://www.python.org/')
print f.read(100)
m getting this error
File "urllib.py", line 13, in <module>
import urllib2
File "/usr/lib/python2.7/urllib2.py", line 111, in <module>
from urllib import (unwrap, unquote, splittype, splithost, quote,
File "/home/vclub/vclubdev/vclubcms/urllib.py", line 14, in <module>
f = urllib2.urlopen('http://www.python.org/')
AttributeError: 'module' object has no attribute 'urlopen'
Please suggest what i need to do for solving this error .
You have a file called
urllib.pyin your working directory. It’s confusing Python’simportmechanism.You should rename it.