{"id":9076,"library":"libigl","title":"libigl Python Bindings","description":"libigl provides Python bindings for the C++ libigl library, a powerful and simple geometry processing toolkit. It offers a wide range of functionalities, including discrete differential geometry operators, finite-element matrices, and mesh topology data structures. The current version is 2.6.2, and the library is actively developed with frequent releases.","status":"active","version":"2.6.2","language":"en","source_language":"en","source_url":"https://github.com/libigl/libigl-python-bindings","tags":["geometry processing","mesh","3d","bindings","c++","numpy","scipy","nanobind"],"install":[{"cmd":"pip install libigl","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Required Python version.","package":"python","version":">=3.8"},{"reason":"Fundamental for dense matrix and vector operations.","package":"numpy","optional":false},{"reason":"Used for sparse matrix operations.","package":"scipy","optional":false}],"imports":[{"note":"All libigl functions are exposed directly under the 'igl' module.","symbol":"igl","correct":"import igl"},{"note":"Functions are direct attributes of the 'igl' module.","symbol":"read_triangle_mesh","correct":"import igl\nV, F = igl.read_triangle_mesh('path/to/mesh.obj')"}],"quickstart":{"code":"import igl\nimport numpy as np\nimport os\n\n# Create a simple mesh (triangle on the XY plane)\nV = np.array([\n    [0.0, 0.0, 0.0],\n    [1.0, 0.0, 0.0],\n    [0.0, 1.0, 0.0]\n], dtype=np.float64)\nF = np.array([\n    [0, 1, 2]\n], dtype=np.int32)\n\n# Define a path for saving/loading\noutput_dir = os.environ.get('LIBIGL_OUTPUT_DIR', '.')\noutput_mesh_path = os.path.join(output_dir, 'example_triangle.obj')\n\n# Save the mesh\nsuccess = igl.write_triangle_mesh(output_mesh_path, V, F)\nprint(f\"Mesh saved successfully: {success} to {output_mesh_path}\")\n\n# Load the mesh back\nV_loaded, F_loaded = igl.read_triangle_mesh(output_mesh_path)\nprint(f\"Loaded Vertices shape: {V_loaded.shape}, Faces shape: {F_loaded.shape}\")\n\n# Example: Calculate edge lengths (requires a function like igl.edge_lengths)\n# This is illustrative; actual function name might vary and require more imports.\n# If igl.edge_lengths existed, it might look like:\n# L = igl.edge_lengths(V, F)\n# print(f\"Edge lengths: {L}\")\n\n# Cleanup (optional)\n# os.remove(output_mesh_path)\n","lang":"python","description":"This quickstart demonstrates how to create a simple mesh, save it to a file using `igl.write_triangle_mesh`, and then load it back using `igl.read_triangle_mesh`. It uses NumPy arrays for vertex coordinates and face connectivity. For interactive visualization, additional libraries like `meshplot` (not included here) are often used."},"warnings":[{"fix":"Review the official GitHub repository and tutorials for updated API usage. Many functions or their signatures may have changed.","message":"Major breaking changes were introduced in versions 2.5.4.dev0, carrying forward into 2.6.0 and later. These versions involved a complete rewrite of the Python bindings source code and the build system (transitioning to nanobind). Code written for pre-2.5.4.dev0 versions will likely require significant updates.","severity":"breaking","affected_versions":">=2.5.4.dev0"},{"fix":"To programmatically get the installed package version, use `importlib.metadata.version('libigl')`.","message":"The `igl.__version__` attribute was removed in version 2.5.4.dev0. Directly accessing this attribute will raise an `AttributeError`.","severity":"deprecated","affected_versions":">=2.5.4.dev0"},{"fix":"Refer to the `libigl-python-bindings` GitHub repository's `tutorial` and `tests` directories for current usage patterns and examples, and the core C++ `libigl` documentation for function details.","message":"The official Python binding documentation is noted as 'perennially out of date' and may be removed or changed. Users should prioritize the GitHub repository's README, examples, and the C++ libigl documentation for the most accurate and up-to-date information.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `libigl` is installed by running `pip install libigl`. Verify the correct Python environment is active if using virtual environments.","cause":"The `libigl` Python package is not installed in the current Python environment or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'igl'"},{"fix":"Install `meshplot` (or another visualization library like `matplotlib`, `vedo`, etc.) separately: `pip install meshplot`. Ensure it's imported correctly: `from meshplot import plot`.","cause":"The `libigl` library itself does not include plotting functionality. Visualization in tutorials often relies on external libraries like `meshplot`.","error":"NameError: name 'plot' is not defined (or similar plotting errors like 'display is undefined')"},{"fix":"For standard usage, install the pre-compiled wheels via `pip install libigl` rather than building from source. If building from source is necessary, ensure Git and CMake are installed and accessible, and check network connectivity to GitHub.","cause":"This error typically occurs when attempting to install `libigl` from source (e.g., `pip install .` in a cloned repo) and the build process fails to clone the underlying C++ `libigl` library or its dependencies, often due to network issues, firewall restrictions, or missing Git/CMake.","error":"Failed to clone repository: 'https://github.com/libigl/libigl.git/' (or similar CMake/Git errors during installation)"}]}