pythonpyinstallerpanda3d

How to make a executable using Panda3D and Pyinstaller in Python?


I'm trying to make an executable with this code(only for testing):

from panda3d.core import loadPrcFile
from direct.showbase.ShowBase import ShowBase


class Game(ShowBase):

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


def main() -> None:

    loadPrcFile('file.prc')

    Game().run()


if __name__ == '__main__':
    main()

when I try to make it up with pyinstaller I get this:

Warning: unable to auto-locate config files in directory named by "<auto>etc".

enter image description here


Solution

  • Don't use pyinstaller, Panda3D is configured for setuptools.

    Create a requirements.txt file, in this file add: Panda3D

    Than create a setup.py file, in this file add the following code:

    from setuptools import setup
    
    setup(
        name="tester",
        options = {
            'build_apps': {
                'include_patterns': [
                    '**/*.png',
                    '**/*.jpg',
                    '**/*.egg',
                ],
                'gui_apps': {
                    'tester': 'main.py',
                },
                'log_append': False,
                'plugins': [
                    'pandagl',
                    'p3openal_audio',
                ],
                'platforms':['win_amd64']
            }
        }
    )
    

    Both files the requirements.txt and the setup.py should be in the folder where your Panda3D files are.

    Don't forget to change tester: to_your_file_name.py in setup.py file.

    Open a cmd window in the folder where the setup.py file is.

    Run this command in your cmd:

    python setup.py build_apps
    

    This will create a windows 64 bit executable from yor Panda3D application in the build folder. There you will find the tester.exe file.

    If you are using 3D models with textures, make sure they are also copied next to the executable file.

    If you want to learn more check out the docs: https://docs.panda3d.org/1.10/python/distribution/index