3

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
gary
  • 4,227
  • 3
  • 31
  • 58
Jenny
  • 31
  • 1
  • 2
  • Can we see the code that generates the installer? – Peter C Nov 05 '10 at 21:10
  • FILES =
    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
    – Jenny Nov 05 '10 at 21:20

2 Answers2

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

Shish
  • 2,773
  • 19
  • 16
  • I tried this. It did not work. pyinstaller --clean -F app.py --path /home/robertja/.local/lib/python2.6/site-packages/pysnmp-4.2.5-py2.6.egg/pysnmp/smi:/home/robertja/.local/lib/python2.6/site-packages/pysnmp-4.2.5-py2.6.egg/pysnmp/smi/mibs:/home/robertja/.local/lib/python2.6/site-packages/pysnmp-4.2.5-py2.6.egg/pysnmp/smi/mibs/instances – Robert Jacobs Feb 14 '14 at 21:43
  • looks like you're using "--path" rather than "--paths" (though it's been so long I can't remember which was right, and don't know which is right in the current version) – Shish Feb 16 '14 at 11:36
  • Long option allows shortened options. Also used -p which is the same. – Robert Jacobs Feb 16 '14 at 12:23
0

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

Sarah Messer
  • 3,592
  • 1
  • 26
  • 43