Reputation: 43
I'm having problems with using from pydrake.all import (MathematicalProgram, Polynomial)
after building drake from source (reference https://drake.mit.edu/python_bindings.html). Per the previous link, installation steps were:
git clone https://github.com/RobotLocomotion/drake.git
mkdir drake-build
cd drake-build
cmake ../drake -DWITH_MOSEK=ON
make -j
cd drake-build
export PYTHONPATH=${PWD}/install/lib/python3.6/site-packages:${PYTHONPATH}
After installing and running from pydrake.all import (MathematicalProgram, Polynomial)
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "$HOME/drake-build/install/lib/python3.6/site-packages/pydrake/all.py", line 34, in <module>
from .perception import *
ImportError: ImportError: $HOME/drake-build/install/lib/python3.6/site-packages/pydrake/systems/framework.so: undefined symbol: _ZNK5drake7systems6SystemIdE19DoCheckValidContextERKNS0_11ContextBaseE
I don't get this error if I use the nightly build binaries (instead of building from source), but I'm having separate problems with the nightly build binaries and want to rely on building from git.
Using Ubuntu 18.04, Python3.6.
Upvotes: 2
Views: 1512
Reputation: 43
Solved by removing the build directory and repeating the steps given in https://drake.mit.edu/python_bindings.html#building-the-python-bindings:
rm -rf drake-build
mkdir drake-build
cd drake-build
cmake ../drake -DWITH_MOSEK=ON
make -j
cd drake-build
export PYTHONPATH=${PWD}/install/lib/python3.6/site-packages:${PYTHONPATH}
A previous build must have gone wonky and the vestiges were preventing a correct build afterwards. I'm not sure on the root cause of the first "bad build," but it doesn't seem to be related to the commit I was previously on (4bd63e3ee) since the re-build from that commit is also working fine.
Upvotes: 2
Reputation: 2766
Have you tried to set your PYTHONPATH environment variable? You could do
cd drake-build
export PYTHONPATH=${PWD}/install/lib/python3.6/site-packages:${PYTHONPATH}
as mentioned in https://drake.mit.edu/python_bindings.html#building-the-python-bindings
Upvotes: 1