LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-20-2021, 12:43 AM   #1
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,834

Rep: Reputation: 108Reputation: 108
ModuleNotFoundError: No module named 'html.entities'; 'html' is not a package (python3 error)


Hya,

Situation While converting python2 script to python3, I ran into this error.
Code:
ModuleNotFoundError: No module named 'html.entities'; 'html' is not a package
Steps to this error: With a good python2 script, it is converted to by 2to3, and minor modification (from . import foo -> import foo)
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. No additional message at the end of diff output.

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.

Last edited by kaz2100; 05-20-2021 at 01:09 AM. Reason: add: from . import; diff output message
 
Old 05-20-2021, 01:59 AM   #2
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,834

Original Poster
Rep: Reputation: 108Reputation: 108
Hya,

self reply, not solved yet.

Under interactive mode
Code:
>>> import html.entities
>>>
It works. Is there anything like import order/incompatibility problem?

cheers
 
Old 05-24-2021, 09:06 PM   #3
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy .. bullseye bookworm
Posts: 1,834

Original Poster
Rep: Reputation: 108Reputation: 108
self reply.

It turned out to be that this problem is same as this one.

cheers
 
Old 05-25-2021, 12:48 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
different python versions may (and should) have different PYTHONPATH settings and you need to install your modules using the appropriate one (including python2.X.Y and any python3.X.Y)
I guess mixing it is not a good idea (=using packages from another python version)
also python2to3 will not install modules for you (but modules installed for python2 will not be available any more).
 
  


Reply

Tags
2to3, error, module, python3



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] apt install broken - ConfigParser import SafeConfigParser ModuleNotFoundError: No module named 'ConfigParser' anon052 Linux - Newbie 16 08-06-2020 06:11 AM
[SOLVED] making python3.6.4 default python3 Astral Axiom Linux - Newbie 17 04-14-2018 10:55 AM
[SOLVED] how to start python3.6 interpreter just by typing python in terminal not python3.6 bmohanraj91 Linux - Newbie 4 05-10-2017 07:51 AM
After upgrade python3.4 to python3.5.1 , not able to install packages "request" though pip3 YOGESHAS87 Linux - Software 1 08-03-2016 10:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration