{"id":6812,"library":"pyrender","title":"Pyrender","description":"Pyrender is a pure Python library (compatible with Python 2.7, 3.4, 3.5, 3.6, though recent Python versions have known issues) for physically-based rendering and visualization. It adheres to the glTF 2.0 specification and provides both an interactive scene viewer and an offscreen renderer capable of GPU-accelerated rendering on headless servers, making it well-suited for machine learning applications. It is lightweight, easy to install, and designed for simplicity of use. The current version is 0.1.45, with development continuing on GitHub.","status":"active","version":"0.1.45","language":"en","source_language":"en","source_url":"https://github.com/mmatl/pyrender","tags":["3d","rendering","visualization","opengl","gltf","machine-learning"],"install":[{"cmd":"pip install pyrender","lang":"bash","label":"Install Pyrender"}],"dependencies":[{"reason":"Recommended for loading and manipulating various 3D mesh types (OBJ, STL, DAE, PLY, etc.) due to deep integration with Pyrender's mesh objects.","package":"trimesh","optional":false}],"imports":[{"note":"Primary import for all Pyrender functionalities.","symbol":"pyrender","correct":"import pyrender"},{"note":"Access classes and functions as attributes of the main 'pyrender' module.","symbol":"Mesh","correct":"import pyrender\nmesh = pyrender.Mesh(...)"},{"note":"Access classes and functions as attributes of the main 'pyrender' module.","symbol":"Scene","correct":"import pyrender\nscene = pyrender.Scene(...)"},{"note":"Access classes and functions as attributes of the main 'pyrender' module.","symbol":"Viewer","correct":"import pyrender\nviewer = pyrender.Viewer(...)"}],"quickstart":{"code":"import trimesh\nimport pyrender\n\n# Load a mesh (e.g., a simple box)\nfuze_trimesh = trimesh.creation.icosphere()\nmesh = pyrender.Mesh.from_trimesh(fuze_trimesh)\n\n# Create a scene\nscene = pyrender.Scene()\nscene.add(mesh)\n\n# Add a camera\ncamera = pyrender.PerspectiveCamera(yfov=0.8, aspectRatio=1.0)\ncamera_pose = [1.0, 0.0, 0.0, 0.0,\n               0.0, 1.0, 0.0, 0.0,\n               0.0, 0.0, 1.0, 3.0,\n               0.0, 0.0, 0.0, 1.0]\nscene.add(camera, pose=camera_pose)\n\n# Add some lighting\nlight = pyrender.DirectionalLight(color=[1.0, 1.0, 1.0], intensity=3.0)\nlight_pose = [0.0, 0.0, 0.0, 0.0,\n              -0.5, 0.8, 0.0, 0.0,\n               0.0, 0.0, 1.0, 0.0,\n               0.0, 0.0, 0.0, 1.0]\nscene.add(light, pose=light_pose)\n\n# View the scene\npyrender.Viewer(scene, use_raymond_lighting=True)","lang":"python","description":"This quickstart demonstrates how to load a basic mesh using `trimesh`, add it to a Pyrender scene, set up a camera and lighting, and then display the scene in an interactive viewer. For offscreen rendering, a `pyrender.OffscreenRenderer` would be used instead of `pyrender.Viewer`."},"warnings":[{"fix":"Consider installing directly from the GitHub repository (`pip install git+https://github.com/mmatl/pyrender.git`) to get the latest fixes, or use an older Python version (e.g., 3.11 or lower).","message":"Pyrender versions on PyPI (including 0.1.45) may be broken on Python 3.12 and 3.13 due to an OpenGL compatibility issue (specifically with OpenGL 3.1.0). A fix exists in the GitHub repository but has not yet been released to PyPI as of late 2025.","severity":"breaking","affected_versions":"0.1.45 (and possibly earlier) on Python >= 3.12"},{"fix":"Refer to the official Pyrender documentation's 'Installation Guide' and 'Offscreen Rendering' sections for detailed instructions on configuring OSMesa or EGL for your environment.","message":"Offscreen rendering on headless servers often requires specific setup for OpenGL contexts. You might need to install/rebuild Mesa with OSMesa support or ensure EGL 1.5 is available for GPU acceleration.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Manually install the compatible `pyglet` fork: `git clone https://github.com/mmatl/pyglet.git && cd pyglet && pip install .` before installing `pyrender`.","message":"MacOS users may encounter issues with OpenGL contexts when using `pyrender` due to an unreleased `pyglet` fix. A specific fork of `pyglet` is required.","severity":"gotcha","affected_versions":"All versions on MacOS"},{"fix":"For the most up-to-date and potentially more stable version (especially for newer Python environments), install Pyrender directly from its GitHub repository: `pip install git+https://github.com/mmatl/pyrender.git`.","message":"The latest PyPI release (0.1.45) is from February 2021. Important bug fixes and improvements that have landed in the GitHub repository since then are not available via `pip install pyrender`.","severity":"gotcha","affected_versions":"<=0.1.45"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}