2015-03-05 14 views

Odpowiedz

10

Utworzono lokalny plik o nazwie o nazwie html.py, który maskuje e standardowy pakiet biblioteczny.

Zmień nazwę lub usuń; można zlokalizować go z:

python3 -c "import html; print(html.__file__)" 

Demo:

naga:stackoverflow-3.4 mpieters$ touch html.py 
naga:stackoverflow-3.4 mpieters$ bin/python -c 'from html.parser import HTMLParser' 
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 "<string>", line 1, in <module> 
ImportError: No module named 'html.parser'; 'html' is not a package 
naga:stackoverflow-3.4 mpieters$ bin/python -c "import html; print(html.__file__)" 
/.../stackoverflow-3.4/html.py 
naga:stackoverflow-3.4 mpieters$ rm html.py 
naga:stackoverflow-3.4 mpieters$ bin/python -c 'from html.parser import HTMLParser; print("Succeeded")' 
Succeeded 
5

Masz plik html.py (lub html.pyc) gdzieś w Python path:

$ touch html.py 
$ python3 -c 'import html.parser' 
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 "<string>", line 1, in <module> 
ImportError: No module named 'html.parser'; 'html' is not a package 

Wystarczy zmienić nazwę pliku (do myhtml.py). Jeśli nie masz pewności, gdzie to jest, możesz wydrukować jego lokalizację przy pomocy

# Insert temporarily before the problematic line 
import html 
print(html.__file__)