PyInstaller executable not working with panda3d. No graphics pipe availabe

385 Views Asked by At

I am having an issue with a program, which uses panda3d. It works perfectly when executed as a pythonscript, but the version, which is compiled (or rather packaged) by PyInstaller throws the exception below.

:display(warning): Unable to load libpandagl.so: No error.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
  File "Shipsim3d_1-1.py", line 930, in <module>
  File "Shipsim3d_1-1.py", line 23, in __init__
  File "direct/showbase/ShowBase.py", line 339, in __init__
  File "direct/showbase/ShowBase.py", line 1024, in openDefaultWindow
  File "direct/showbase/ShowBase.py", line 1059, in openMainWindow
  File "direct/showbase/ShowBase.py", line 769, in openWindow
  File "direct/showbase/ShowBase.py", line 749, in <lambda>
  File "direct/showbase/ShowBase.py", line 821, in _doOpenWindow
  File "direct/showbase/ShowBase.py", line 650, in makeDefaultPipe
  File "direct/directnotify/Notifier.py", line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.
[5466] Failed to execute script 'Shipsim3d_1-1' due to unhandled exception!

Usually, there is a Config.prc file in the etc subdirectory of the panda3d site-package directory. This file is non-existent in the packaged version. But if I create this subdirectory there, and copy the files to it as well, it still doesn't work and it still throws the same exception. There is a line "loadPrcData("win-size 1080 1920")" in my main program as well. Could this be part of the problem in any way? Or is there something else i am missing?

Thanks in advance

2

There are 2 best solutions below

2
On BEST ANSWER

I solved this problem by including the whole panda3d lib: pyinstaller --add-data="path/to/panda3d;panda3d" -wF main.py

0
On

The accepted answer adds all the binaries, which can make the size of the created executable a little heavy. Instead just the required files can be added. In your .spec file in Analysis add:

binaries=[('path_to_panda3d/libpandagl.so', 'panda3d/.'), 
    ('path_to_panda3d/libCgGL.so', 'panda3d/.'),
    ('path_to_panda3d/libp3headlessgl.so', 'panda3d/.'), 
    ('path_to_panda3d/libp3openal_audio.so', 'panda3d/.')],
datas=[('path_to_panda3d/etc', 'panda3d/etc')],

The etc folder consists of the config prc files, while the .so binaries are enough for the graphics pipeline in the default config and the audio file is required to ensure that works fine.

If you want to work through command line that can also be done using --add-data and --add-binary.