stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.7k stars 366 forks source link

ImportError: cannot import name 'casadi' from 'pinocchio' #2159

Closed lrchit closed 4 months ago

lrchit commented 4 months ago

Bug description

I'm doing nmpc with casadi and acados. Recently I need some dynamics to build a model, such as Centroid dynamics. So I tried to bind pinocchio with casadi using python. When I did cmake and make, everything went well. But when I tried python, something was wrong. After everything was installed, I ran python3 and tried "from pinocchio import casadi", at which errors occured as followings: image

image

Code

Considering something needs eigenpy 2.7.10, I installed it in advanced. I used following steps to build pinocchio with a virtual environment:

virtualenv env --python=/usr/bin/python3
source env/bin/activate
pip install cmake casadi compilers
pip install pinocchio
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_WITH_CASADI_SUPPORT=ON
sudo make install

I tested pinocchio with my previous C++ project and that did well. As there was nothing wrong when compiling, I don't know how to solve this. Is there anything wrong with the virtual environment or cmake procedure? Thanks in advance!

System

jcarpent commented 4 months ago

You can install pinocchio3 preview with modern features via conda directly. I recommend using the procedure detailed here: https://github.com/agimus-project/winter-school-2023/tree/main/simulation/sim1_rigid_body

Best, Justin

lrchit commented 4 months ago

You can install pinocchio3 preview with modern features via conda directly. I recommend using the procedure detailed here: https://github.com/agimus-project/winter-school-2023/tree/main/simulation/sim1_rigid_body

Best, Justin

Dear Justin, I followed https://github.com/agimus-project/winter-school-2023/tree/main/simulation/sim1_rigid_body. At first time, I used python3.8 and it turned out the same error. And I thus tried python3.10, and it made it! Thanks a lot for your kindness!

Cheers! Lrc