我有一个脚本正在尝试使用 Python 2.7 使用 PyInstaller (2.1) 进行编译
该脚本使用我编写的名为“auto_common”的自定义包
在脚本中,我使用以下命令导入它
sys.path.append(path_to_package)
项目文件夹如下所示:
Automation/ Top level project
Proj1/
script1.py This is the script I want to compile
myspec.spec Spec file for the script
Packages/
auto_common/
__init__.py Init module of the package (empty)
... More modules here
在 PyInstaller 日志文件中,我收到以下警告:
W: no module named auto_common (top-level import by __main__)
如何创建一个包含该包的挂钩(例如使用 sys.path.append)?
我尝试将包的路径添加到规范文件中的“pathex”,但它不起作用。
编译时(或构建规范文件时)使用“-p”将向 python 路径添加额外的路径。
pyinstaller -p any_path/Automation/Packages script1.py
这模仿了 sys.path.append() 的行为。
感谢 PyInstaller 的人员提供的解决方案:
使用 PyInstaller 2.1 编译时 sys.path.append 不起作用 http://www.pyinstaller.org/ticket/903
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)