Reputation: 914
I have a script I'm trying to compile with PyInstaller (2.1) using Python 2.7
The script uses a custom package I've written called 'auto_common'
In the script I import it by using
sys.path.append(path_to_package)
The project folders look like this:
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
In the PyInstaller log file I get the following warning:
W: no module named auto_common (top-level import by __main__)
How do I create a hook which will include the package (using sys.path.append for example)?
I tried adding the path of the package to 'pathex' in the spec file but it didn't work.
Upvotes: 9
Views: 9987
Reputation: 914
Using "-p" when compiling (or when building a spec file) will add additional paths to python's path.
pyinstaller -p any_path/Automation/Packages script1.py
This mimics the behavior of sys.path.append().
Thanks to the guys at PyInstaller for the solution:
sys.path.append does not work when compiling with PyInstaller 2.1
Upvotes: 10