http.py
# -*- coding: utf-8 -*-
import http.server
server_address = ("", 8000)
handler_class = http.server.CGIHTTPRequestHandler #1 Set handler
server = http.server.HTTPServer(server_address, handler_class)
server.serve_forever()
As mentioned above, when setting up an http server that listens on localhost 8000, I was worried because the following message was output, so Tips.
error_log
C:\Python34\python.exe C:/Users/xxx/PycharmProjects/untitled/http.py
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 "C:/Users/xxx/PycharmProjects/untitled/http.py", line 3, in <module>
import http.server
File "C:\Users\xxx\PycharmProjects\untitled\http.py", line 3, in <module>
import http.server
ImportError: No module named 'http.server'; 'http' is not a package
I changed the file name to http.py, so changing it to test.py etc. will work.
This time it is http, but depending on the external module to be imported, Please note that other file names may also be out.
Recommended Posts