ModuleNotFoundError: No module named 'html.entities'; 'html' is not a package (python3 error)
by kaz2100 from LinuxQuestions.org on (#5J1QG)
Hya,
Situation While converting python2 script to python3, I ran into this error.Code:ModuleNotFoundError: No module named 'html.entities'; 'html' is not a packageSteps to this error: With a good python2 script, it is converted to by 2to3, and minor modification
System: Debian amd64, python 3.9.1
Troubleshooting
Related 2to3 log follows:Code:-import htmlentitydefs
+import html.entities
- for name, char in htmlentitydefs.entitydefs.items():
+ for name, char in list(html.entities.entitydefs.items()):So, it may be related to 2to3. Errer occured at the import statement.
1.1 Several html.py files exist under /usr/lib/python3 ( /usr/lib/python3/dist-packages/IPython/html.py, /usr/lib/python3/dist-packages/humanfriendly/terminal/html.py, /usr/lib/python3/dist-packages/wx/html.py, /usr/lib/python3/dist-packages/pygments/formatters/html.py
/usr/lib/python3/dist-packages/pygments/lexers/html.py, /usr/lib/python3/dist-packages/prompt_toolkit/formatted_text/html.py)
1.2 It does not look like there is class/function/variable named entities. (I am not familiar with modulename.itemname. Tutorial section 6.1 says it is ok.)
2. This site mentions about this error.
I am a kind of lost at this moment. If the former scenario, the error message is not quite correct. If the latter, it is 5 years old bug/issue. I need to figure out what I am missing.
Question Does anybody know how to solve this?
Closing remark Have a happy penguin!
Any clue will be appreciated.


Situation While converting python2 script to python3, I ran into this error.Code:ModuleNotFoundError: No module named 'html.entities'; 'html' is not a packageSteps to this error: With a good python2 script, it is converted to by 2to3, and minor modification
System: Debian amd64, python 3.9.1
Troubleshooting
Related 2to3 log follows:Code:-import htmlentitydefs
+import html.entities
- for name, char in htmlentitydefs.entitydefs.items():
+ for name, char in list(html.entities.entitydefs.items()):So, it may be related to 2to3. Errer occured at the import statement.
1.1 Several html.py files exist under /usr/lib/python3 ( /usr/lib/python3/dist-packages/IPython/html.py, /usr/lib/python3/dist-packages/humanfriendly/terminal/html.py, /usr/lib/python3/dist-packages/wx/html.py, /usr/lib/python3/dist-packages/pygments/formatters/html.py
/usr/lib/python3/dist-packages/pygments/lexers/html.py, /usr/lib/python3/dist-packages/prompt_toolkit/formatted_text/html.py)
1.2 It does not look like there is class/function/variable named entities. (I am not familiar with modulename.itemname. Tutorial section 6.1 says it is ok.)
2. This site mentions about this error.
I am a kind of lost at this moment. If the former scenario, the error message is not quite correct. If the latter, it is 5 years old bug/issue. I need to figure out what I am missing.
Question Does anybody know how to solve this?
Closing remark Have a happy penguin!
Any clue will be appreciated.