Il mio codice funziona perfettamente in PyCharm, ma ho dei messaggi di errore durante il tentativo di aprirlo nel terminale. Cosa c'è che non va nel mio codice o dove ho fatto degli errori?Python 3: AttributeError: l'oggetto 'module' non ha attributo '__path__' usando urllib nel terminale
import urllib.request
with urllib.request.urlopen('http://python.org/') as response:
html = response.read()
print(html)
uscita dal terminale:
λ 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 the above exception, another 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' is not a package
'urllib.request' importazione è valido ??? –
@VivekSable, sì per python3. –