Pyinstaller and panda3d

Hello I’m currently trying to compile a simple panda3d script into an exe with pyinstaller, I have had zero luck with packp3d :confused: I’ve gotten pretty far with pyinstaller, I was able to get the final exe to run the panda3d Tutorial snippet however if I go ahead and import pandac.PandaModules it completely breaks the compiled exe (works in the py file)?! This is the output from the exe: pandac.PandaModules : ImportError: Cannot import name getConfigShowbase

I found this spec file on the forums here but had to modify it some, Im thinking it’s probably the culprit for not finding pandac, or some other missing piece pandac is calling but im really not sure:

PANDA_DIR = 'C:\\Panda3d-1.9.0'

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(['exe_panda3d.py'],
             pathex=['C:\\Users\\nathan\\Desktop\\ptest'])

pyz = PYZ(a.pure)

exe = EXE(pyz,
          a.scripts,
          a.binaries+P3DmissingDLLs,
        PKG(P3DruntimeLibraries+P3Detc,name='test.pkg'),
          name='TestP3DInstaller.exe',
          debug=True,
          strip=False,
          upx=True,
          console=True )

And this is the code Im using

from math import pi, sin, cos

# Culprit breaking exe???
from pandac.PandaModules import *

from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.actor.Actor import Actor
from direct.interval.IntervalGlobal import Sequence
from panda3d.core import Point3

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
 
        # Disable the camera trackball controls.
        self.disableMouse()
 
        # Load the environment model.
        self.environ = self.loader.loadModel("models/environment.bam")
        # Reparent the model to render.
        self.environ.reparentTo(self.render)
        # Apply scale and position transforms on the model.
        self.environ.setScale(0.25, 0.25, 0.25)
        self.environ.setPos(-8, 42, 0)
 
        # Add the spinCameraTask procedure to the task manager.
        self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
 
        # Load and transform the panda actor.
        self.pandaActor = Actor("models/panda-model.bam",
                                {"walk": "models/panda-walk4.bam"})
        self.pandaActor.setScale(0.005, 0.005, 0.005)
        self.pandaActor.reparentTo(self.render)
        # Loop its animation.
        self.pandaActor.loop("walk")
 
        # Create the four lerp intervals needed for the panda to
        # walk back and forth.
        pandaPosInterval1 = self.pandaActor.posInterval(13,
                                                        Point3(0, -10, 0),
                                                        startPos=Point3(0, 10, 0))
        pandaPosInterval2 = self.pandaActor.posInterval(13,
                                                        Point3(0, 10, 0),
                                                        startPos=Point3(0, -10, 0))
        pandaHprInterval1 = self.pandaActor.hprInterval(3,
                                                        Point3(180, 0, 0),
                                                        startHpr=Point3(0, 0, 0))
        pandaHprInterval2 = self.pandaActor.hprInterval(3,
                                                        Point3(0, 0, 0),
                                                        startHpr=Point3(180, 0, 0))
 
        # Create and play the sequence that coordinates the intervals.
        self.pandaPace = Sequence(pandaPosInterval1,
                                  pandaHprInterval1,
                                  pandaPosInterval2,
                                  pandaHprInterval2,
                                  name="pandaPace")
        self.pandaPace.loop()
 
    # Define a procedure to move the camera.
    def spinCameraTask(self, task):
        angleDegrees = task.time * 6.0
        angleRadians = angleDegrees * (pi / 180.0)
        self.camera.setPos(20 * sin(angleRadians), -20.0 * cos(angleRadians), 3)
        self.camera.setHpr(angleDegrees, 0, 0)
        return Task.cont
 
app = MyApp()
app.run()

Thanks for any help!

That error indicates that libp3direct wasn’t found, or couldn’t be loaded properly. If you’re using a recent build from GitHub we now import this from panda3d.direct directly rather than via PandaModules, though, so it shouldn’t be an issue with a recent enough build.

Though it’d still be nice to know what sort of issues you ran into with packp3d.

Ok! I got compiled the latest version of panda3d from the github page and it did help! but now I’m getting this error message from the exe: “direct.interval.IntervalManager”, line 13, in (module) NameError: name ‘CIntervalManager’ is not defined. I feel like it’s sooo close to working ahh :cry:

Same issue; CIntervalManager is also imported from libp3direct (old) or panda3d.direct (new).

Is there a specific branch of Panda3d on the github that I need? I downloaded the source and compiled it last night? so I would guess that I have the latest version now???

What happens when you add this to IntervalManager.py?

from panda3d.direct import CIntervalManager

I added that line of code into the IntervalManager.py and recompiled the exe now windows is saying that the exe has stopped working and the output is: Classes TypedReferenceCount and TypedReferenceCount share the same TypeHandle value (5); check class definitions

Odd. That usually means that some Panda DLL was loaded into memory more than once.

Sooo dose that mean I should try and grit my teeth and try using packp3d? Alot of my problems I think with packp3d were pathing issues but I would have to try again to find out exactly

You’d certainly be going down a more well-trodden path. It’s likely that some of us have already seen the packp3d issues in some form or another, so feel free to ask if you run into trouble.

Have you ever tried pdeploy?

panda3d.org/manual/index.ph … _installer

I don’t like packpanda so I use pdeploy.

But I’m not sure if this will help you though…

That’s probably what he meant - but to create an .exe with pdeploy, you first need to use packp3d.