When I am importing `http.server` from the idle it works, but when I run a python file having `import http.server` there is an error

http, module, python, python-3.x

Solution

You have named your file as `http.py`, Thus it is overriding the original module `http`

To solve

- change the name of the file to something else

- Remove the `pyc` file

- Run the program again

Problem

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!

Original source