Python interface under miniconda environment [Mac]

Hi :wave:

  • Python
  • miniconda
  • Mac

While running minimal_example_ocp.py, I have

(sci) ➜  ocp git:(master) /usr/local/Caskroom/miniconda/base/envs/sci/bin/python /Users/kexianshen/repo/acados/examples/acados_python/getting_started/ocp/minimal_example_ocp.py
using simulink json-file: "/Users/kexianshen/repo/acados/interfaces/acados_template/acados_template/simulink_default_opts.json"
rm -f libacados_ocp_solver_pendulum_ode.so
rm -f acados_solver_pendulum_ode.o
( cd pendulum_ode_model ; gcc -fPIC -std=c99    -c  pendulum_ode_expl_ode_fun.c pendulum_ode_expl_vde_forw.c)
gcc -fPIC -std=c99    -c acados_solver_pendulum_ode.c -I /Users/kexianshen/repo/acados/include/blasfeo/include/ -I /Users/kexianshen/repo/acados/include/hpipm/include/ \
        -I /Users/kexianshen/repo/acados/include -I /Users/kexianshen/repo/acados/include/acados/ \

acados_solver_pendulum_ode.c:137:13: warning: data argument not used by format string [-Wformat-extra-args]
            "but the number of shooting intervals (= %d) differs from the number of " \
            ^
1 warning generated.
gcc -fPIC -std=c99    -shared -o libacados_ocp_solver_pendulum_ode.so  acados_solver_pendulum_ode.o  pendulum_ode_model/pendulum_ode_expl_ode_fun.o pendulum_ode_model/pendulum_ode_expl_vde_forw.o \
        -I /Users/kexianshen/repo/acados/include/blasfeo/include/ \
        -I /Users/kexianshen/repo/acados/include/hpipm/include/ \
        -I /Users/kexianshen/repo/acados/include \
        -L -l \
        -L /Users/kexianshen/repo/acados/lib -lacados -lhpipm -lblasfeo \
         \
        -lm \

ld: warning: directory not found for option '-L-l'
Traceback (most recent call last):
  File "/Users/kexianshen/repo/acados/examples/acados_python/getting_started/ocp/minimal_example_ocp.py", line 102, in <module>
    ocp_solver = AcadosOcpSolver(ocp, json_file = 'acados_ocp.json')
  File "/Users/kexianshen/repo/acados/interfaces/acados_template/acados_template/acados_ocp_solver.py", line 825, in __init__
    self.shared_lib = CDLL(self.shared_lib_name)
  File "/usr/local/Caskroom/miniconda/base/envs/sci/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(c_generated_code/libacados_ocp_solver_pendulum_ode.so, 6): Library not loaded: libhpipm.dylib
  Referenced from: /Users/kexianshen/repo/acados/examples/acados_python/getting_started/ocp/c_generated_code/libacados_ocp_solver_pendulum_ode.so
  Reason: image not found
Exception ignored in: <function AcadosOcpSolver.__del__ at 0x7fc1a1861ee0>
Traceback (most recent call last):
  File "/Users/kexianshen/repo/acados/interfaces/acados_template/acados_template/acados_ocp_solver.py", line 1539, in __del__
    model = self.acados_ocp.model
AttributeError: 'AcadosOcpSolver' object has no attribute 'acados_ocp'
(sci) ➜  ocp git:(master) echo $LD_LIBRARY_PATH
:/Users/kexianshen/repo/acados/lib
(sci) ➜  ocp git:(master) ls /Users/kexianshen/repo/acados/lib
libacados.dylib        libhpipm.dylib         libqpOASES_e.dylib
libblasfeo.dylib       libqpOASES_e.3.1.dylib link_libs.json

I have set LD_LIBRARY_PATH where libhpipm.dylib locates.

Hi,

I think on Mac DYLD_LIBRARY_PATH is what LD_LIBRARY_PATH is on Linux.
Can you export the path to DYLD_LIBRARY_PATH and let me know if it works?

It works, thank you.

1 Like