I am following the example from the python online document(21.12.3) for practice. When I try to run my script with Run Module(F5), I always get an import error. But if I type them directly into IDLE command line, python does not complain. I am not sure what am I doing wrong.
The python version I am using is Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32
The script is
import http.client
conn = http.client.HTTPConnection("192.168.1.2", 8080)
conn.request("GET", "/index.html")
r1 = conn.getresponse()
print(r1.status, r1.reason)
conn.close()
The error message is
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\User\Downloads\http.py", line 1, in <module>
import http.client
File "D:\User\Downloads\http.py", line 1, in <module>
import http.client
ImportError: No module named 'http.client'; 'http' is not a package