Need help with PyInstaller

So I’ve been working on some basic stuff to get the feel for Panda, and I decided now sooner then later I’m going to need to put this into a standalone EXE. I’ve tried both py2exe and pyinstaller but both seem to be giving me problems. I get farther with pyinstaller though. I can get it to spit out a nice-sized EXE which makes it look like everything went in ok, but when it is run it can’t ever find the direct tree. Can anybody take a look at this spec file and tell me if anything’s wrong? I’m using Panda 1.5.2 and the pyinstaller SVN, btw.

#****************************************PANDA3D******************************************************
PANDA_DIR = 'C:\\Panda3d-1.5.2'
import sys, os, glob
# some C/C++ runtime libraries, machine without these .dlls will crash Panda3D
runtimeLibraries=glob.glob(os.path.join(PANDA_DIR, 'bin/*.manifest'))+\
                 glob.glob(os.path.join(PANDA_DIR, 'bin/vcredist*.exe'))
P3DruntimeLibraries=[]
for r in runtimeLibraries:
   P3DruntimeLibraries.append( (r[r.rfind('\\')+1:],r,'DATA') )

P3DmissingDLLs = []
for d in os.listdir(os.path.join(PANDA_DIR, 'bin/')):
   if d[-4:] != '.dll': continue
   P3DmissingDLLs.append( (d,os.path.join(PANDA_DIR,'bin/%s' %d),'BINARY') )

P3Detc = Tree(os.path.join(PANDA_DIR, 'etc/'),prefix='etc/')
#*******************************************************************************************************

a = Analysis([os.path.join(HOMEPATH,'C:\\pyinstaller\\support\\_mountzlib.py'),
            os.path.join(HOMEPATH,'C:\\pyinstaller\\support\\useUnicode.py'),
            'main.py', 'MainMenu.py'],
             pathex=['C:\\pyinstaller'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          a.binaries+P3DmissingDLLs,
        PKG(P3DruntimeLibraries+P3Detc,name='data.pkg'),
          name='Awesome Ball.exe',
          debug=False,
          strip=False,
          upx=True,
          console=True ) 

Also, as my first post I’d like to say that this looks like one hell of a community, lots of people seem to be getting helped and it’s a rare site to see with all the forums I’ve been on.

Hmm… Your spec file looks fine to me.

However, have you moved the folders found in <panda_dir>\direct\src to <panda_dir>\direct (that is, simply out of the “src” folder), deleted the “src” folder (although deleting it may not be important), and commented out the contents of <panda_dir>\direct_init_.py (but not deleted it)?

It looks as though you’re using the advice from either my own recent thread on the topic; have you also placed at the top of your main.py (or analogous file) the code suggested by mindstormss?

(By the way, you say that you get a “nice-sized EXE” - what size do you get, if I may ask?)

The only problem I see with adding that code into Main.py is not being able to run it from an actual python interpreter. I tried moving the source directory contents but that didn’t seem to do much, I’m going to try that again.

Alright, that still didn’t work, might be getting closer I think, it starts to run but then it spits out this:

DirectStart: Starting the game.
Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "C:\pyinstaller\iu.py", line 400, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\pyinstaller\iu.py", line 484, in doimport
    exec co in mod.__dict__
  File "C:\Documents and Settings\Kyle\Desktop\Devel\Awesome Ball\build\pyi.win3
2\AwesomeBall\outPYZ2.pyz/direct.directbase.DirectStart", line 3, in <module>
  File "C:\pyinstaller\iu.py", line 441, in importHook
    mod = self.doimport(nm, ctx, ctx+'.'+nm)
  File "C:\pyinstaller\iu.py", line 484, in doimport
    exec co in mod.__dict__
  File "C:\Documents and Settings\Kyle\Desktop\Devel\Awesome Ball\build\pyi.win3
2\AwesomeBall\outPYZ2.pyz/direct.showbase.ShowBase", line 10, in <module>
  File "C:\pyinstaller\iu.py", line 400, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\pyinstaller\iu.py", line 484, in doimport
    exec co in mod.__dict__
  File "C:\Documents and Settings\Kyle\Desktop\Devel\Awesome Ball\build\pyi.win3
2\AwesomeBall\outPYZ2.pyz/pandac.PandaModules", line 2, in <module>
  File "C:\pyinstaller\iu.py", line 400, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\pyinstaller\iu.py", line 484, in doimport
    exec co in mod.__dict__
  File "C:\Documents and Settings\Kyle\Desktop\Devel\Awesome Ball\build\pyi.win3
2\AwesomeBall\outPYZ2.pyz/pandac.libpandaModules", line 2, in <module>
  File "C:\Documents and Settings\Kyle\Desktop\Devel\Awesome Ball\build\pyi.win3
2\AwesomeBall\outPYZ2.pyz/pandac.extension_native_helpers", line 35, in Dtool_Pr
eloadDLL
ImportError: DLL load failed: Invalid access to memory location.

And the EXE is about 22 MB, which seems better then the 30+ that some people have talked about with packpanda.

“DLL load failed”? That does sound odd…

I think that it might be the lack of the code at the start of the file. As to it interfering with interpreter use, I don’t recall having problems with SPE, but I might be wrong, since I was focussing on getting PyInstaller to work at the time. ^^;

Have you tried a file with that code in your current editor or from a Python prompt? If so, what happened?

At worst you can just comment it out while you’re working with it, and uncomment it when it comes time to package.

Otherwise, it occurs to me that you didn’t mention the state of your init.py file, in the <panda_dir>\direct directory. As I recall, you should have both that present, with all lines commented out, and the directories from “src” moved to “direct”. As I recall, I had problems because I did one and not the other.

As to the size, fair enough, and thanks. :slight_smile: