[New-bugs-announce] [issue7121] ImportError of urllib.request & http.client under PYTHONHOME/Lib

mike report at bugs.python.org
Wed Oct 14 06:57:09 CEST 2009

New submission from mike <mikezp59 at gmail.com>:

There's a python program in the attached file http.py, I import
urllib.request in http.py, and urllib.request imports http.client.

  When I try to run http.py by command "python http.py", the error is as

Traceback (most recent call last):
  File "http.py", line 4, in <module>
    import urllib.request
  File "C:\Program Files\Python311\lib\urllib\request.py", line 86, in
    import http.client
  File "D:\program\python\http.py", line 6, in <module>
    response = urllib.request.urlopen('http://python.org/')
AttributeError: 'module' object has no attribute 'request'

   However, if I copy http.py to directory PYTHONHOME/Lib and run
command "python http.py" under directory PYTHONHOME/Lib, it works
successfully; if you move it to other directories and run the command,
the error will be returned.

   Note: the source code of http.py is copied from python311.chm under
directory PYTHONHOME/Doc.

components: Library (Lib)
files: http.py
messages: 93965
nosy: mikezp59
severity: normal
status: open
title: ImportError of urllib.request & http.client under PYTHONHOME/Lib
type: compile error
versions: Python 3.1
Added file: http://bugs.python.org/file15121/http.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list