About new urllib.request in python 3.1.2

pcchen luke0104 at gmail.com
Sat Jul 10 10:06:47 EDT 2010


Sorry I have searched related topic but none could point out this
problem.

I am currently using python 3.1.2:

>>>Python 3.1.2 (r312:79147, Jun 30 2010, 11:58:11)
>>>[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8

And for the following three simple lines of code, borrowed from
official python-doc 3.1.2:

>>>from urllib.request import urlopen
>>>response = urlopen('http://python.org/')
>>>html = response.read()

They could cause this error:

  File "./http.py", line 3, in <module>
    from urllib.request import urlopen
  File "/usr/local/lib/python3.1/urllib/request.py", line 88, in
<module>
    import http.client
  File "/home/pcchen/Python/http.py", line 3, in <module>
    from urllib.request import urlopen
ImportError: cannot import name urlopen

All the related discussions point to urlopen has been moved from
urllib to urllib.request, but none can discribe the above error.

Any information is appreciated, thank you so much.



More information about the Python-list mailing list