Blank window with packp3d

I was trying to package my game today, but after I ran packp3d, and then panda3d file.p3d, I only got a blank/gray window.

After that, I also tried to pack another game, but with the same result. Both games run with python I don’t know if this matters, but I made both of them with the Panda3D IDE, leaving all default imports active.
These are the imports:

# Panda3D imports _____________________________________
import direct.directbase.DirectStart
from pandac.PandaModules import *
from import Actor
from direct.showbase.DirectObject import DirectObject
from direct.gui.DirectGui import *
from direct.gui.OnscreenText import OnscreenText
from direct.gui.OnscreenImage import OnscreenImage
from direct.interval.IntervalGlobal import *
from direct.task import Task
from direct.showbase import PythonUtil as PU

# Python imports ______________________________________
import imp, glob
import os, sys
import string, re
import cPickle
import random
import math
import time
import types
import traceback

I don’t know if there’s more I should write here, but ask if you need to know anything else.

Check the log file, which is in Panda3D/log/p3dsession.log, where Panda3D is the hard-to-find runtime installation directory for Panda3D that varies according to your operating system.


Are you using

if __name__ == "__main__":

in your

If so you could either remove this check, or check for “main” instead of “main”, since Panda3D runtime defines name to be the string “main” and not the “main”.

Thank you very much, enn0x, now it works!

Note that the difference between “main” and “main” is the difference between “python” and “import main”. The plugin uses an approach more similar to the latter.


Hm, David, would it be an idea to change the name variable to main when running the user’s

Certainly, but I don’t know if that’s what we ought to do. That would make the plugin act sort as if you had run it from the command line with “python”, instead of from Python with “import main”.

But that’s not the way it’s really working, and I’m not sure it buys us anything to fool the developer into thinking that it is. Why would you protect your code with an “if name == ‘main’” unless you really only wanted that code to run when you invoked it from the command line? And why would you think that running a p3d file is like running it from the command line?


Good point. But I think it will certainly reduce confusion to do so, given that a lot of developers already use it.

I think they use it because they don’t want a module import to do any funny things or even block the execution in this case. So someone who imported main would be free to use the functions exposed in it, but it wouldn’t block the execution.

All right, it’s a persuasive argument. I’ll make the change.


FWIW I made this change for the upcoming 1.9 runtime distribution; in the future, packp3d will package the main module as having the name main rather than main, mirroring how Python packages work.