简体   繁体   English

PyInstaller:“导入错误:没有名为 htmlentitydefs 的模块”

[英]PyInstaller: “ImportError: No module named htmlentitydefs”

I made the executable with pyinstaller like this (no --onefile or other options)我用这样的 pyinstaller 制作了可执行文件(没有 --onefile 或其他选项)

> 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.编辑:我使用 cx_freeze 创建的 .exe 得到相同的ImportError ,所以它似乎与打包程序无关。

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).另外要添加一些信息,我刚刚重新安装了 Python 和必要的模块,并且之前在执行相同操作时没有出现此错误(尽管我确实遇到了其他错误)。

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. htmlentitydefs 模块已在 Python 3 中重命名为 html.entities。 2to3 工具将在将您的源代码转换为 Python 3 时自动调整导入。

Use html.entities instead of htmlentitydefs使用html.entities而不是htmlentitydefs

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM