When I Am Using:
>>> import http.server
in the IDLE
there isn't any error.
But When I am Using This Piece Of Code:
import http.server
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
def run(server_class = HTTPServer, handler_class = BaseHTTPRequestHandler):
server_address = ('', 8000)
httpd=server_class(server_address, handler_class)
httpd.serve_forever()
run()
There Is An Error Which Is As Follows:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2195, 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 "/home/toton/Projects/http.py", line 1, in <module>
import http.server
File "/home/toton/Projects/http.py", line 1, in <module>
import http.server
ImportError: No module named 'http.server'; 'http' is not a package
Please Help!
You have named your file as http.py
, Thus it is overriding the original module http
To solve
pyc
fileIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With