Python 3: AttributeError: 'module' object has no attribute '__path__' using urllib in terminal -
my code runnning in pycharm, have error messages while trying open in terminal. what's wrong code, or made mistakes?
import urllib.request urllib.request.urlopen('http://python.org/') response: html = response.read() print(html)
output terminal:
λ python desktop\url1.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 above exception, exception occurred: traceback (most recent call last): file "desktop\url1.py", line 1, in <module> import urllib.request file "c:\users\przemek\desktop\urllib.py", line 1, in <module> import urllib.request importerror: no module named 'urllib.request'; 'urllib' not package
you called file c:\users\przemek\desktop\urllib.py
, need rename it. importing not actual module. rename c:\users\przemek\desktop\urllib.py
, remove c:\users\przemek\desktop\urllib.pyc
.
it not file running have file in same directory python checks current directory first hence error.
Comments
Post a Comment