skip to Main Content

After successful compiling drake_cxx_python I have got:
Output of python3 -c 'import pydrake.all; print(pydrake.__file__)':

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/dmitriy/git/drake-build/install/lib/python3.8/site-packages/pydrake/all.py", line 31, in <module>
    from .autodiffutils import *
ImportError: libmosek64.so.9.3: cannot open shared object file: No such file or directory

I use this command sequence:

rm -rfv drake-build
git clone https://github.com/RobotLocomotion/drake.git
mkdir drake-build
cd drake-build
cmake -DWITH_GUROBI=ON -DWITH_MOSEK=ON ../drake
../drake/setup/ubuntu/source_distribution/install_prereqs_user_environment.sh 
make -j4

Next I specify PATH by adding it to /.bashrc file:

#drake
cd ~/git/drake-build/
export PYTHONPATH=${PWD}/install/lib/python3.8/site-packages:${PYTHONPATH}
cd

The output of sudo python3 -c 'import pydrake.all; print(pydrake.__file__)':

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pydrake'

I installed Mosek use that: instructions

Output of ldd install/lib/python3.8/site-packages/pydrake/solvers/__init__.cpython-38-x86_64-linux-gnu.so | grep -i mosek:

    libmosek64.so.9.3 => not found
    libmosek64.so.9.2 => not found

Output of readelf -d install/lib/python3.8/site-packages/pydrake/solvers/__init__.cpython-38-x86_64-linux-gnu.so | grep -i path:

 0x000000000000001d (RUNPATH)            Library runpath: [/usr/lib/x86_64-linux-gnu/lapack/:/usr/lib/x86_64-linux-gnu/blas/]

And at the same time, there is a file libmosek64.so.9.3*:

~/git/drake-build/install/lib$ l -a
./
../
cmake/
libcilkrts.so.5*
libddApp.so*
libdrake_ibex.so*
libdrake_lcm.so*
libdrake_marker.so*
libdrake.so*
libgurobi95.so@
libgurobi.so.9.5.1*
libmosek64.so.9.3*

Why it doesn’t see it?

I tried install drake using pip and I have got the same error:
output of python3 -c 'import pydrake.all; print(pydrake.__file__)':

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/dmitriy/git/drake-build/install/lib/python3.8/site-packages/pydrake/all.py", line 31, in <module>
    from .autodiffutils import *
ImportError: libmosek64.so.9.3: cannot open shared object file: No such file or directory

2

Answers


  1. See https://drake.mit.edu/from_source.html#building-the-python-bindings for instructions.

    Pasting it into here:


    To use the Python bindings from Drake externally, we recommend using CMake.
    As an example:

    git clone https://github.com/RobotLocomotion/drake.git
    mkdir drake-build
    cd drake-build
    cmake ../drake
    make -j
    

    Please note the additional CMake options which affect the Python bindings:

    • -DWITH_GUROBI={ON, [OFF]} – Build with Gurobi enabled.
    • -DWITH_MOSEK={ON, [OFF]} – Build with MOSEK™ enabled.
    • -DWITH_SNOPT={ON, [OFF]} – Build with SNOPT enabled.

    {...} means a list of options, and the option surrounded by [...] is
    the default option. An example of building pydrake with both Gurobi and
    MOSEK™, without building tests:

    cmake -DWITH_GUROBI=ON -DWITH_MOSEK=ON ../drake
    

    You will also need to have your PYTHONPATH configured correctly.

    Ubuntu 20.04 (Focal):

    cd drake-build
    export PYTHONPATH=${PWD}/install/lib/python3.8/site-packages:${PYTHONPATH}
    

    macOS:

    cd drake-build
    export PYTHONPATH=${PWD}/install/lib/python3.9/site-packages:${PYTHONPATH}
    

    In particular, in the steps you quoted above, there was no mention of PYTHONPATH. Setting a correct PYTHONPATH is required to use Drake correctly.


    Using Drake git sha e4330af2c97a14170f873b25eb42fa0449feac9d:

    When I run these commands:

    mkdir 73219153
    cd 73219153
    git clone https://github.com/RobotLocomotion/drake.git
    mkdir drake-build
    cd drake-build
    cmake -DWITH_GUROBI=OFF -DWITH_MOSEK=ON ../drake
    ../drake/setup/ubuntu/source_distribution/install_prereqs_user_environment.sh 
    make -j30
    export PYTHONPATH=${PWD}/install/lib/python3.8/site-packages:${PYTHONPATH}
    python3 -c 'import pydrake.all; print(pydrake.__file__)'
    

    … then it works for me. Here’s what I see for library paths:

    jwnimmer@call-cps:~/tmp/73219153/drake-build$ readelf -d install/lib/python3.8/site-packages/pydrake/solvers/__init__.cpython-38-x86_64-linux-gnu.so | grep -i path
     0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../../../..:/usr/lib/x86_64-linux-gnu/lapack/:/usr/lib/x86_64-linux-gnu/blas/]
    jwnimmer@call-cps:~/tmp/73219153/drake-build$ ldd install/lib/python3.8/site-packages/pydrake/solvers/__init__.cpython-38-x86_64-linux-gnu.so | grep -i mosek
        libmosek64.so.9.3 => /home/jwnimmer/tmp/73219153/drake-build/install/lib/python3.8/site-packages/pydrake/solvers/../../../../libmosek64.so.9.3 (0x00007fbd03626000)
    

    I don’t know why your library paths aren’t working. You’ll need to provide better reproduction instructions.

    Login or Signup to reply.
  2. I don’t know why you are seeing two versions of MOSEK required. Are you repeatedly installing Drake into the same install folder over and over? That’s not how CMake works. With CMake, you need to rm -rf the install folder prior to re-running any install. Otherwise, it never cleans up any old files, and they could be corrupting the install. In particular, this is probably https://github.com/RobotLocomotion/drake/issues/14224.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search