Generated p3d-file does not start/run on Windows

Hi,

I generated a p3d from my small game with packp3d (after solving the missing packp3d.p3d in 1.7.0). When starting the generated p3d with Panda a console window appears with:

Then nothing happens, the download image appears (after it downloaded everything) and the p3dpythonw.exe generates massive CPU load. I let the program run for 20 Minutes and nothing happened.

The p3d can be downloaded from here. The last lines in p3dcore.log are:

Any ideas?

Thanks,
Enrico[/url]

Try running the p3d file from the command line, with the command “panda3d -f myfile.p3d”. This will (a) show you the Python log output, which may give you a clue where it’s getting hung up, and (b) the -f parameter works around a minor bug in the 1.7.0 release of panda3d.exe.

David

Hi,

I just tried that command on Windows XP with Panda 1.7.0 and Ubuntu 10.04 with the latest version from the build bot. In both cases, there are no messages in the console window, nothing happens and both processes generate loads of CPU load :frowning:

Edit: With a generated standalone executable happens the same :frowning:

OK, I’m guessing your Python code is not importing DirectStart, or otherwise not doing anything interesting at startup.

What is the Python code in your main.py?

David

Hi,

I just installed panda3d and panda3d-runtime from the Ubuntu PPA. My main class is:

class Game(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        # some more code...

I imported DirectStart now, which gives me at least a gray window. Do I have to derive from DirectStart to make p3d-files work?

Thanks,
Enrico

No, sorry, I’ve misled you.

The bottom line is, your program should run if you execute “python -c ‘import main’”. If it doesn’t, then it won’t run when you pack it into a p3d file either.

In your case, you have two choices: either import DirectStart, or derive from ShowBase and then remember to create an instance of your class in main.py. You should only have exactly one instance of ShowBase, never two; and importing DirectStart will create an instance of ShowBase, so you shouldn’t both import DirectStart and also derive from ShowBase in the same program.

Since you are deriving from ShowBase, it means you shouldn’t import DirectStart, but it does mean you need to have this line in your main.py:

game = Game()

David

Hi David,

I did not know that with ShowBase and DirectStart. I will remove that DirectStart-import (it works right now).

I found the problem: In my code I have

if __name__ == "__main__":
    # run game....

so I can easily import that code into other modules.

In the P3D-environment is name set to “main” and then my check does not work anymore.

Thanks for your help!! :slight_smile:

Yes, that seems to be a common mistake. People assume that importing main.py in the p3d file is the same as running it on the command line, which would set the name to “main” instead of “main”.

We’ve talked about making this change in practice, to make it more consistent with people’s expectations. If we did so, then it would be correct to check for name == “main”. The only problem with this is, it’s still not the same as running it on the command line; in particular, there’s an issue with the GIL and threads that behaves differently from a command-line file and from an explicitly-imported file. But for most naive uses, it will be the same.

David

Maybe you should add a note to the packp3d manual then :wink: