Import http.client encouter import error with Python 3.4.1

I had the same problem. In my case, there was another file named http.py in the same folder. I just renamed it, problem solved.


You probably have created a Python script and named it http.py in local directory. This conflicts with Python 3's builtin module with the same name and leads to this error. Quick solution is to rename your file to something less generic to avoid conflict with Python builtin modules.

But if you insist, you can clear the name ambiguity by fully qualifying the local python module name using absolute imports:

from . import http

or less confusingly:

from . import http as myhttp

or

from .http import something

On Python 2, it is necessary to enable the absolute import feature at the very top of the importing module using a future statement before using this feature:

from __future__ import absolute_import