简体   繁体   中英

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

如果你要自定义模块路径以便导入这些库(例如,我在源代码树中的./lib/文件夹中捆绑了一些非标准库),那么你应该在--paths=lib上添加它们。 pyinstaller命令行 - 在代码中间有sys.path.append(“lib”)不起作用(如果它找不到它们,不知道它是如何设法编译的,但它确实如此,这个花了一段时间追查...)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM