Nir*_*Nir 7 python hook pyinstaller
我有一个脚本,我正在尝试使用Python 2.7使用PyInstaller(2.1)进行编译
该脚本使用我编写的名为'auto_common'的自定义包
在脚本中我使用导入它
sys.path.append(path_to_package)
Run Code Online (Sandbox Code Playgroud)
项目文件夹如下所示:
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
Run Code Online (Sandbox Code Playgroud)
在PyInstaller日志文件中,我收到以下警告:
W: no module named auto_common (top-level import by __main__)
Run Code Online (Sandbox Code Playgroud)
如何创建一个包含包的钩子(例如使用sys.path.append)?
我尝试在spec文件中将包的路径添加到'pathex',但它不起作用.
在编译时(或在构建spec文件时)使用"-p"将添加到python路径的其他路径.
pyinstaller -p any_path/Automation/Packages script1.py
Run Code Online (Sandbox Code Playgroud)
这模仿了sys.path.append()的行为.
感谢PyInstaller的解决方案:
使用PyInstaller 2.1进行编译时,sys.path.append不起作用