{"id":23175,"library":"tetgen","title":"TetGen Python Interface","description":"Python wrapper for the TetGen tetrahedral mesh generator, providing high-quality tetrahedral meshing of 3D polyhedral domains. Currently at version 0.8.3, with releases approximately every 6-12 months. Part of the PyVista ecosystem.","status":"active","version":"0.8.3","language":"python","source_language":"en","source_url":"https://github.com/pyvista/tetgen","tags":["tetgen","tetrahedral","mesh","finite-element","pyvista","3d"],"install":[{"cmd":"pip install tetgen","lang":"bash","label":"latest stable"}],"dependencies":[{"reason":"core dependency for array operations","package":"numpy","optional":false},{"reason":"recommended for visualization and mesh handling","package":"pyvista","optional":true}],"imports":[{"note":"class name is 'TetGen' with capital T and G, not lowercase","wrong":"from tetgen import tetgen","symbol":"TetGen","correct":"from tetgen import TetGen"}],"quickstart":{"code":"import pyvista as pv\nfrom tetgen import TetGen\n\n# Load or create a surface mesh (must be a closed, manifold PolyData)\nmesh = pv.Sphere()\n\n# Initialize TetGen with the surface\ntet = TetGen(mesh)\n\n# Generate tetrahedral mesh (apply attributes/flags as needed)\ntet.tetrahedralize()\n\n# Access the resulting tetrahedral mesh\ntet_grid = tet.grid\nprint(tet_grid)\n","lang":"python","description":"Load a surface mesh, create a TetGen instance, tetrahedralize, and access the output mesh."},"warnings":[{"fix":"Upgrade and re-test tetrahedralizations. Avoid relying on Cython-specific behavior.","message":"In v0.8.0, the Cython backend was replaced with nanobind. This may cause subtle differences in numerical results and break custom builds.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Use tet.cell_quality instead of tet.compute_cell_quality.","message":"Method compute_cell_quality was renamed to cell_quality in v0.6.7.","severity":"deprecated","affected_versions":">=0.6.7"},{"fix":"Use Python 3.10+.","message":"Version 0.8.3 requires Python >=3.10. No wheels for older Python versions.","severity":"breaking","affected_versions":">=0.8.3"},{"fix":"Clean the input mesh (e.g., with PyVista's clean, merge, or manifold checks) before passing to TetGen.","message":"TetGen expects a closed, manifold surface mesh. Non-manifold or open meshes will fail silently or produce incorrect results.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install tetgen'. Ensure import uses lowercase 'tetgen'.","cause":"Package not installed or misspelled.","error":"ModuleNotFoundError: No module named 'tetgen'"},{"fix":"Use 'from tetgen import TetGen'.","cause":"Incorrect import statement; 'TetGen' is the class.","error":"ImportError: cannot import name 'TetGen' from 'tetgen'"},{"fix":"Check mesh closure with 'mesh.is_all_manifold' and 'mesh.is_closed'. Repair as needed.","cause":"Input surface mesh is not closed, is non-manifold, or has self-intersections.","error":"RuntimeError: TetGen returned 0 tetrahedra"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}