【问题标题】:Can't compile Python using Nuitka无法使用 Nuitka 编译 Python
【发布时间】:2026-01-01 14:00:01
【问题描述】:

我正在尝试编译使用 urllib.request、BeautifulSoup 和 网络浏览器。

$ nuitka python.py
Nuitka:WARNING:python.py:16: Cannot find 'urllib.request' as relative or absolute import.
Nuitka:WARNING:python.py:17: Cannot find 'bs4' as relative or absolute import.

$ ./python.exe
Traceback (most recent call last):
  File "python.py", line 16, in <module>
    from urllib.request import urlopen
ImportError: No module named request

【问题讨论】:

  • 我不知道 nuitka 是什么,但 no module named request 看起来很像 python2 与 python3 不匹配。
  • 在您的问题中包含 bs4 和 request 的导入语句,以及您的文件名。

标签: python python-3.x ubuntu nuitka


【解决方案1】:

尝试在 Nuitka 执行期间将--recurse-to=urllib 添加到命令行。 有关详细信息,请参阅 Nuitka 帮助。

【讨论】: