{"id":8483,"library":"pyglm","title":"PyGLM: OpenGL Mathematics library for Python","description":"PyGLM is an OpenGL Mathematics library for Python, providing vector and matrix types, and mathematical functions for graphics programming. It is a Python extension written in C++ that wraps the popular GLM (OpenGL Mathematics) library. The current version is 2.8.3. It maintains an infrequent but active release cadence, focusing on stability and compatibility with its underlying C++ counterpart.","status":"active","version":"2.8.3","language":"en","source_language":"en","source_url":"https://github.com/Zuzu-Typ/PyGLM","tags":["opengl","mathematics","graphics","glm","vector","matrix","computergraphics"],"install":[{"cmd":"pip install pyglm","lang":"bash","label":"Install PyGLM"}],"dependencies":[],"imports":[{"note":"The module is imported as 'glm'. In PyGLM versions 2.7.3 and earlier, 'try: from pyglm import glm except ImportError: import glm' was suggested. Direct 'import glm' is currently the standard but will be deprecated in PyGLM 3.0 in favor of 'from pyglm import glm'.","wrong":"from pyglm import glm (before v2.8), import pyglm","symbol":"glm","correct":"import glm"}],"quickstart":{"code":"import glm\n\n# Vector operations\nv = glm.vec3()\nv.x = 7\nprint(f\"v.xxy: {v.xxy}\")\n\n# Matrix initialization\nm = glm.mat4()\nprint(f\"m:\\n{m}\")\n\n# Vector arithmetic with iterables\nv_sum = glm.vec4(1, 2, 3, 4) + (8, 7, 6, 5)\nprint(f\"v_sum: {v_sum}\")","lang":"python","description":"This quickstart demonstrates basic vector and matrix initialization and operations using the `glm` module. It shows how to create vectors and matrices, access components, and perform arithmetic operations."},"warnings":[{"fix":"Update your import statement from `import glm` to `from pyglm import glm`.","message":"The direct import `import glm` will be deprecated in PyGLM 3.0. Users should transition to `from pyglm import glm` for future compatibility.","severity":"breaking","affected_versions":">=3.0 (future)"},{"fix":"Refer to the PyGLM documentation or wiki for specific syntax differences when porting C++ GLM code.","message":"PyGLM's syntax differs from the original C++ GLM library in several ways, including using `.` instead of `::` for namespaces (e.g., `glm.vec2`), requiring `_LH` suffix for left-handed coordinate system functions (e.g., `glm.perspectiveLH`), and using default `packed_highp` precision.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `glm.silence(ID)` to silence specific warnings, or `glm.silence(0)` to silence all warnings. Check the `glm` module's function reference for warning IDs.","message":"Certain functions, like `glm.frexp`, may issue a `UserWarning`. These can be silenced if desired.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Copy the `COPYING` or `GLM_LICENSE` file from the PyGLM source to your project directory.","message":"The GLM C++ library, which PyGLM wraps, is licensed under the MIT License. Users are required to include the GLM license (`COPYING` or `GLM_LICENSE` file) in their projects, especially for binary distributions.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure you installed `pyglm` and not `glm`. Uninstall `glm` (`pip uninstall glm`) and then install the correct package (`pip install pyglm`).","cause":"This error typically occurs when the wrong `glm` package has been installed. There is another package named `glm` on PyPI which is a JSON parser, not the OpenGL Mathematics library.","error":"AttributeError: module 'glm' has no attribute 'vec2'"},{"fix":"On Windows, install the 'Desktop development with C++' workload from the Visual Studio Installer. On Linux, ensure `build-essential` (Debian/Ubuntu) or `Development Tools` (Fedora/RHEL) are installed.","cause":"PyGLM is a C++ extension and requires C++ build tools to be present on your system if a pre-compiled wheel is not available for your specific Python version and operating system. On Windows, this often means Visual C++ Build Tools.","error":"ERROR: Failed building wheel for pyglm"}]}