开发者

Libraries not imported when creating a Python executable with pyinstaller

开发者 https://www.devze.com 2023-01-23 23:07 出处:网络
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 we

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


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...)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消