{"id":5207,"library":"eigenpy","title":"EigenPy","description":"EigenPy provides seamless Python bindings between NumPy arrays and Eigen C++ dense matrix types, utilizing Boost.Python. It allows for efficient data exchange and manipulation, exposing Eigen types and operations directly to Python. The current version is 3.12.0, with a release cadence that tends to follow updates in underlying dependencies or related projects like Pinocchio and Crocoddyl.","status":"active","version":"3.12.0","language":"en","source_language":"en","source_url":"https://github.com/cmake-wheel/eigenpy","tags":["bindings","numpy","eigen","c++","scicomp","robotics"],"install":[{"cmd":"pip install eigenpy","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"Core functionality relies on interoperability with NumPy arrays.","package":"numpy","optional":false}],"imports":[{"note":"The primary module exposing Eigen types and conversion utilities.","symbol":"eigenpy","correct":"import eigenpy"},{"note":"Must be called once to register Eigen types and enable conversions.","symbol":"enableEigenPy","correct":"eigenpy.enableEigenPy()"},{"note":"In EigenPy v3.x, Eigen types like MatrixXd are directly under the 'eigenpy' namespace, not 'eigenpy.hpp' as in older versions.","wrong":"eigenpy.hpp.MatrixXd","symbol":"MatrixXd","correct":"eigenpy.MatrixXd"},{"note":"Converts a NumPy array to an Eigen matrix (creates a copy by default).","symbol":"toEigen","correct":"eigenpy.toEigen"},{"note":"Converts an Eigen matrix to a NumPy array (creates a view by default).","symbol":"toNumpy","correct":"eigenpy.toNumpy"}],"quickstart":{"code":"import eigenpy\nimport numpy as np\n\n# IMPORTANT: Enable EigenPy functionality\neigenpy.enableEigenPy()\n\n# Create an Eigen MatrixXd instance (from C++ bindings)\nmat_eigen = eigenpy.MatrixXd(3, 3)\nmat_eigen.setRandom()\nprint('Eigen MatrixXd (random):\\n', mat_eigen)\n\n# Convert Eigen matrix to NumPy array (creates a view by default)\nnp_view = np.asarray(mat_eigen)\nprint('\\nNumPy view of Eigen matrix:\\n', np_view)\n\n# Modifying the NumPy view also modifies the underlying Eigen matrix\nnp_view[0, 0] = 99.0\nprint('\\nEigen MatrixXd after NumPy view modification:\\n', mat_eigen)\n\n# Convert NumPy array to Eigen matrix (creates a copy by default)\nnumpy_orig = np.array([[1.0, 2.0], [3.0, 4.0]])\nmat_eigen_from_np = eigenpy.toEigen(numpy_orig)\nprint('\\nEigen matrix from NumPy array:\\n', mat_eigen_from_np)\n","lang":"python","description":"This quickstart demonstrates the core functionality of EigenPy: enabling the bindings, creating an Eigen matrix, converting it to a NumPy array (showing view semantics), and converting a NumPy array back to an Eigen matrix (showing copy semantics)."},"warnings":[{"fix":"Update your imports: change `from eigenpy.hpp import MatrixXd` or `eigenpy.hpp.MatrixXd` to `from eigenpy import MatrixXd` or `eigenpy.MatrixXd`.","message":"With the release of EigenPy v3.0.0, the exposed Eigen C++ types moved from a nested namespace (e.g., `eigenpy.hpp.MatrixXd`) directly into the main `eigenpy` module.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure `eigenpy.enableEigenPy()` is called at the beginning of your script or application initialization.","message":"The function `eigenpy.enableEigenPy()` must be called exactly once in your program's lifecycle before any EigenPy functionality (like type conversions or creating Eigen objects) can be used. Forgetting this will lead to errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be explicit about desired memory behavior. For guaranteed copies, use `eigenpy.toNumpyCopy(eigen_matrix)` or `eigenpy.toEigenCopy(numpy_array)`. To work with views, use `np.asarray(eigen_matrix)` carefully.","message":"Conversions between Eigen matrices and NumPy arrays have different memory semantics. Converting an Eigen matrix to NumPy using `np.asarray(eigen_matrix)` creates a *view* (no copy), meaning changes to the NumPy array will reflect in the Eigen matrix. Conversely, converting a NumPy array to Eigen using `eigenpy.toEigen(numpy_array)` creates a *copy* by default.","severity":"gotcha","affected_versions":"All versions, especially >=3.10.0"},{"fix":"Refer to the EigenPy GitHub repository and examples for guidance on integrating custom C++ code with EigenPy bindings.","message":"EigenPy leverages Boost.Python for its bindings. While transparent for basic use, advanced users developing custom C++ extensions that interact with EigenPy might need to ensure their build system (e.g., CMake) correctly links against Boost.Python and Eigen versions compatible with the installed EigenPy wheel.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}