{"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":"python","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,"search_vec":"'0.1.45':81 '2.0':34 '2.7':11 '3.4':12 '3.5':13 '3.6':14 '3d':87 'acceler':51 'adher':30 'applic':64 'base':25 'capabl':47 'compat':8 'continu':84 'current':78 'design':72 'develop':83 'easi':68 'github':86 'gltf':33,91 'gpu':50 'gpu-acceler':49 'headless':54 'instal':70 'interact':40 'issu':21 'known':20 'learn':63,94 'librari':7 'lightweight':67 'machin':62,93 'machine-learn':92 'make':56 'offscreen':45 'opengl':90 'physic':24 'physically-bas':23 'provid':37 'pure':5 'pyrend':1,2 'python':6,10,17 'recent':16 'render':26,46,52,88 'scene':41 'server':55 'simplic':74 'specif':35 'suit':60 'though':15 'use':76 'version':18,79 'viewer':42 'visual':28,89 'well':59 'well-suit':58","created_at":"2026-04-15T18:44:02.797539+00:00","updated_at":"2026-04-16T19:45:39.879116+00:00","problems":[{"fix":"For headless rendering, use a virtual display server like `xvfb` (e.g., `xvfb-run -a python your_script.py`) or configure Pyrender to use an EGL or OSMesa backend, ensuring necessary `mesa` libraries (like `libegl1-mesa-dev` or `libosmesa6-dev`) are installed on your system.","cause":"Pyrender, through its dependency Pyglet, fails to create an OpenGL rendering context when a display server or proper graphics drivers are not available, commonly in headless environments (e.g., servers, Docker containers).","error":"pyglet.gl.lib.GLException: Cannot create GL context"},{"fix":"Ensure your graphics drivers are up-to-date. If running headless, verify that `xvfb` or EGL/OSMesa backends are correctly set up and that compatible `mesa` libraries are installed. Consider upgrading or downgrading `pyrender` and its core dependencies (`pyglet`, `moderngl`, `trimesh`) to known stable versions.","cause":"This severe error often indicates a low-level crash due to issues with OpenGL drivers, memory management, or incompatibility between pyrender and its graphics dependencies (pyglet, moderngl) on specific hardware or operating system configurations, especially when running headless or with outdated drivers.","error":"Segmentation fault (core dumped)"},{"fix":"Upgrade your `trimesh` installation to a version compatible with your `pyrender` version (e.g., `pip install --upgrade trimesh`). If upgrading causes other issues, try installing a specific `trimesh` version known to work with your `pyrender` version, typically found in `pyrender`'s `requirements.txt` on its GitHub repository.","cause":"This error arises when the installed `trimesh` library, a key dependency of `pyrender`, has an API change where `load_image` was moved, renamed, or removed from `trimesh.util`, causing a version incompatibility.","error":"ImportError: cannot import name 'load_image' from 'trimesh.util'"},{"fix":"Ensure `pyrender` and `moderngl` are compatible by upgrading both libraries (e.g., `pip install --upgrade pyrender moderngl`). If the issue persists, check `pyrender`'s official documentation or GitHub `requirements.txt` for the specific `moderngl` version it was developed against and install that version (e.g., `pip install moderngl==X.Y.Z`).","cause":"This `AttributeError` typically occurs due to an incompatibility between your `pyrender` version and the `moderngl` library, which `pyrender` uses for its OpenGL context, implying that the `create_shader_program` method's availability or signature has changed in `moderngl`.","error":"AttributeError: 'Context' object has no attribute 'create_shader_program'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.45","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mmatl/pyrender","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pyrender/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}