Panda3D
Panda3D is a comprehensive, open-source framework for 3D rendering and game development, supporting both Python and C++ programs. It is actively maintained with frequent minor and patch releases, typically focusing on stability, bug fixes, and Python version compatibility. The current version is 1.10.16.
Common errors
-
ImportError: No module named direct.showbase.ShowBase
cause Panda3D's Python modules are not found in the Python path. This can occur if Panda3D was not installed correctly, or if a different Python interpreter (not the one configured for Panda3D) is being used.fixEnsure `panda3d` is installed via `pip install panda3d`. If using a system-wide Python, verify that `PYTHONPATH` or `LD_LIBRARY_PATH` (on Linux) includes the Panda3D installation directories. On Windows, older SDKs required using their bundled Python or copying a `.pth` file. -
Exception: No graphics pipe is available! Have you included a render plug-in, such as `pandagl`, in your setup.py file?
cause This error typically occurs when Panda3D cannot find a suitable graphics API (e.g., OpenGL, DirectX) to render the scene. This can happen in packaged applications (`build_apps`) if render plugins are not included or if the system lacks necessary drivers.fixEnsure your environment has up-to-date graphics drivers. When deploying applications with `build_apps`, explicitly include necessary render plug-ins (e.g., `'pandagl'`) in your `setup.py` file. For debugging, use a non-optimized build (`'use_optimized_wheels': False`). -
Application window closes right away when run (especially after packaging with `build_apps`).
cause When packaging with `build_apps`, console output might be suppressed, making it difficult to see runtime errors. The application crashes before the window can fully initialize or due to a missing dependency.fixFor `build_apps` applications, specify a log file via `log_filename` in `setup.py` to capture error messages. Debug using a non-optimized build. Common causes are missing files or Python version incompatibilities (e.g., Python 3.8.10 fixed in Panda3D 1.10.10). -
KeyError when trying to play an animation on a model.
cause This usually indicates that the model file (e.g., `.egg`) does not contain animation data or the specified animation name is incorrect. Animated models require both geometry and a skeleton to be exported together.fixVerify that the model was correctly exported with animation data. Check the animation names (case-sensitive) used in your code against those embedded in the model. Consult the Panda3D manual for details on exporting animated models.
Warnings
- deprecated The use of `import direct.directbase.DirectStart` and `from pandac.PandaModules import *` is deprecated.
- gotcha Performance can suffer significantly from common pitfalls such as excessive meshes, too many state changes, frequent text updates, and performing complex Python calculations in the main loop.
- gotcha Cg shaders, including the shader generator and `CommonFilters`, do not work on ARM-based machines (e.g., Apple Silicon) due to the unavailability of the NVIDIA Cg Toolkit for arm64 architecture. Cg will be deprecated in future versions.
- gotcha When loading models or specifying file paths in Panda3D functions, use Unix-style forward slashes (`/`) even on Windows, and avoid drive letter prefixes like `C:`. Panda3D's internal filename conventions require this for portability.
Install
-
pip install panda3d
Imports
- ShowBase
import direct.directbase.DirectStart
from direct.showbase.ShowBase import ShowBase
- core classes (e.g., WindowProperties)
from pandac.PandaModules import *
from panda3d.core import WindowProperties
Quickstart
from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Set window properties
props = WindowProperties()
props.setSize(1024, 768)
self.win.requestProperties(props)
# Disable default mouse camera control
self.disableMouse()
print("Panda3D window opened. Close the window to exit.")
app = MyApp()
app.run()