PyInstaller: “ImportError: No module named htmlentitydefs”

sewdio picture sewdio · Jan 3, 2014 · Viewed 7k times · Source

I made the executable with pyinstaller like this (no --onefile or other options)

> pyinstaller brdg2.py

When i run it, here's what i get (screenshot of the command prompt before it closed).

From other threads, the warning at the start seem to be ignorable, so the problem would be

ImportError: No module named htmlentitydefs

Edit: I get the same ImportError with an .exe created with cx_freeze, so it doesn't seem related to the packaging programm.

Also to add some information i had just reinstalled Python and the necessary modules, and i didn't get this error when doing the same operations before (i did get other errors though).

Answer

Sadaf Niknam picture Sadaf Niknam · Jan 2, 2020

The htmlentitydefs module has been renamed to html.entities in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

Use html.entities instead of htmlentitydefs

https://docs.python.org/3/library/html.entities.html