Import custom package PyInstaller 2.1

I have a script I'm trying to compile with PyInstaller (2.1) using Python 2.7

The script uses a special package that I wrote called auto_common

In a script, I import it with

sys.path.append(path_to_package)

Project folders are as follows:

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

The following warning appears in the PyInstaller log file:

W: no module named auto_common (top-level import by __main__)

How to create a hook that will include a package (for example, using sys.path.append)?

I tried adding the package path to 'pathex' in the spec file, but it did not work.

+4
source share
1 answer

Using "-p" when compiling (or when creating a specification file) will add additional paths to the python path.

pyinstaller -p any_path/Automation/Packages script1.py

sys.path.append().

PyInstaller :

sys.path.append PyInstaller 2.1

+4

Source: https://habr.com/ru/post/1525248/


All Articles