Compiling a Panda3D game for distribution

I am trying to compile my game for distribution to others, I want it so they do not need panda3d installed, or python. I tried the Nuitka compiler with no success. Can anyone lead me in the right direction? EDIT: I am also writing in python, and running windows.

This for some reason showed up in my e-mails. I did exactly what you were trying to do a very long time ago.

You should try Nirai, although this is not an official packaging method, and is likely not supported by the Panda3D team. Another way would be to use a p3d file, or use pfreeze. But pfreeze can easily be decompiled, if source hiding is your main concern.

I’ve used Nuitka in the past with success. At which stage did it fail for you?

However, the recommended method for distribution going forward will be deploy-ng, which is being developed for the upcoming 1.10 release of Panda3D. It is an easy way to convert your game into an executable.

Well I tried to use Nirai, but I have not been able to figure it out. I have been trying to figure out a way to compile my game for a few weeks now and it feels hopeless xD

Well, Nuitka ended up finishing as normal, but the exe file opens and closes without giving any log. Any ideas?

Try opening a cmd prompt and running the executable from there. If Python’s set to use the standard console output, you might get a stack trace, or some helpful output.

C:\Users\Christian\Desktop\CogNation-Compile\game\main.dist>main.exe
DirectStart: Starting the game.
Warning: unable to auto-locate config files in directory named by "<auto>etc".
Traceback (most recent call last):
      File "C:\Users\Christian\Desktop\CogNation-Compile\game\main.dist\main.py", line 11, in <module>
  File "C:\Users\Christian\Desktop\CogNation-Compile\game\main.dist\direct\directbase\DirectStart.py", line 
3, in <module direct.directbase.DirectStart>
  File "C:\Users\Christian\Desktop\CogNation-Compile\game\main.dist\direct\showbase\ShowBase.py", line 
10, in <module direct.showbase.ShowBase>
  File "C:\Users\Christian\Desktop\CogNation-Compile\game\main.dist\pandac\PandaModules.py", line 2, in 
<module pandac.PandaModules>
  File "C:\Users\Christian\Desktop\CogNation- 
Compile\game\main.dist\pandac\libpandaexpressModules.py", line 1, in <module 
pandac.libpandaexpressModules>
  File "C:\Users\Christian\Desktop\CogNation- 
Compile\game\main.dist\pandac\extension_native_helpers.py", line 81, in <module 
pandac.extension_native_helpers>
  File "C:\Users\Christian\Desktop\CogNation- 
Compile\game\main.dist\pandac\extension_native_helpers.py", line 79, in Dtool_PreloadDLL
ImportError: dynamic module does not define init function (initlibpandaexpress)

Not sure what this exactly means.
ImportError: dynamic module does not define init function (initlibpandaexpress)

That may be due to an imcompatibility between the version of Python you’re using and the version of Python with which libpandaexpress.dll was compiled. Are you using Python 2 or 3, and which version of Panda are you using?

I dont have python installed, I am just using panda3d-1.8.1’s built in python, which is 2.7 I presume.

Hmm. Maybe it’s searching for the dll and can’t find it. Copy the libpandaexpress.dll file from your Panda3D-1.8.1/bin folder, and paste it in the same directory as your .exe file. Then try running it.

Now it is opening and closing without any error.

Not even in the command prompt? Is it just running and instantly terminating?

Yes. I dont understand why it is doing this.

Some code is doing import libpandaexpress, which isn’t legal. It was legal a very long time ago, but not any more.

I recommend that you get the latest development version. We do not support 1.8.1 any more.

(all display modules loaded.)
Traceback (most recent call last):
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\main.py”, line 5, in
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\directbase\DirectStart.py”, line 5, in
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\showbase\ShowBase.py”, line 265, in init
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\showbase\ShowBase.py”, line 909, in openDefaultWindow
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\showbase\ShowBase.py”, line 945, in openMainWindow
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\showbase\ShowBase.py”, line 659, in openWindow
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\showbase\ShowBase.py”, line 639, in
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\showbase\ShowBase.py”, line 711, in _doOpenWindow
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\showbase\ShowBase.py”, line 548, in makeDefaultPipe
File “C:\Users\Christian\Desktop\CogNation\game\main.dist\direct\directnotify\Notifier.py”, line 131, in error
StandardError: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.

Now I am getting this error. I fixed up the code, and tried compiling several times. I even tried making my code run a custom config.prc to try and get it to run with display
I am running the latest version of panda3d now.
Any suggestions?

Either you’re not including the etc directory (with the Config.prc and Confauto.prc files) or you’re not including the render plug-in, libpandagl.dll, in the directory of your executable.

How can I make Nuitka include those files?

I think they’ll need to exist in the same directory as the executable, not linked inside it. Then it should be able to find it.

Nuitka won’t include those files, you’ll need to copy them yourself.