'Libraries not imported when creating a Python executable with pyinstaller
I am trying to build a Python .exe for Windows and am able to create it fine. However, when I run the application, I notice that it cannot perform all of its functions because not all the libraries were imported; PySNMP is not getting imported in specific. When I look at the output of the build process, I notice that PySNMP is not listed at all, even though several of modules in my program import it. Anyone know what could be causing this issue? Thanks!
Here is the code that generates the installer:
FILES = <main program modules (.py)>
PyInstaller = C:/Python27/pyinstaller
CygPyInstaller = /cygdrive/c/Python27/pyinstaller run : python app.py makespec : $(FILES) @echo "***** PyInstaller: Makespec *****" python $(PyInstaller)/Makespec.py \
--onefile \
--windowed \
--icon=Icons/icon.ico \
--name=Application1045 \
app.py
Solution 1:[1]
if you are customising the module path in order to import these libraries (eg, I have some non-standard libraries bundled in a ./lib/ folder in my source code tree) then you should add them with --paths=lib on the pyinstaller command line -- having sys.path.append("lib") in the middle of the code didn't work (not sure how it managed to compile at all if it couldn't find them, but it did, and this took a while to track down...)
Solution 2:[2]
PyInstaller has had a lot of changes since OP asked the question, but if you're running into these sorts of troubles now, look at the --hiddenimport option
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shish |
| Solution 2 | Sarah Messer |
