Error using cx_freeze with a feedparser import: ModuleNotFoundError: No module named 'sgmllib'

Error using cx_freeze with a feedparser import: ModuleNotFoundError: No module named 'sgmllib'

我正在尝试使用 cx_freeze 冻结使用 Feedparser 的应用程序。如果我使用 python 从命令行启动该应用程序,它会完美运行。但是,当我尝试使用 cx_freeze 冻结它时,直到我尝试启动该应用程序时才出现错误。然后我得到:

Traceback (most recent call last):
  File "/home/ricky/.local/lib/python3.9/site-packages/cx_Freeze/initscripts/__startup__.py", line 66, in run
    module.run()
  File "/home/ricky/.local/lib/python3.9/site-packages/cx_Freeze/initscripts/Console.py", line 36, in run
    exec(code, m.__dict__)
  File "main.py", line 8, in <module>
  File "/home/ricky/.local/lib/python3.9/site-packages/feedparser/__init__.py", line 28, in <module>
    from .api import parse
  File "/home/ricky/.local/lib/python3.9/site-packages/feedparser/api.py", line 36, in <module>
    from .html import _BaseHTMLProcessor
  File "/home/ricky/.local/lib/python3.9/site-packages/feedparser/html.py", line 31, in <module>
    from .sgml import *
  File "/home/ricky/.local/lib/python3.9/site-packages/feedparser/sgml.py", line 30, in <module>
    import sgmllib
ModuleNotFoundError: No module named 'sgmllib'

我知道 sgmllib 在 Python 3 中不再使用,但由于我从命令行启动它时没有收到此错误,所以它似乎不是 feedparser 问题。有什么想法吗?

cx_Freeze 开发人员在 Github 上帮助我解决了同样的问题。 Here's the thread.