我正在使用 pyinstaller 和 staticx 将 Python3.6 脚本编译为静态二进制文件。我已经通过 pip 在虚拟环境(venv)中安装了所有软件包。
一切正常,直到我尝试将该行添加import networkit as nk
到脚本的顶部。编译仍然有效,但是一旦我运行其他未更改的文件,我会收到以下错误:
File "StrategicSolver.py", line 15, in <module>
import networkit as nk
File "<my_path>/strat_solver_env/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "networkit/__init__.py", line 50, in <module>
File "<my_path>/strat_solver_env/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "networkit/graph.py", line 2, in <module>
File "networkit/_NetworKit.pyx", line 6, in init networkit._NetworKit
ModuleNotFoundError: No module named 'networkit.exceptions'
[19811] Failed to execute script StrategicSolver
模块“networkit.exceptions”应该在那里(我也尝试过从源代码安装包python3 setup.py install
),所以我不确定发生了什么。我没有太多从 Python 构建静态二进制文件的经验,因此将不胜感激。