Hi
I’m using the Python acados interface and I’m trying to run the cython example. However, I’m running into the issue that some generated files cannot be found by importlib (see snippet below). I’m running the code on MacOS with an x86 architecture. All other examples (i.e. w/o the cython wrapper) work fine for me.
Could it be linked with the -rpath= flag which is not recognized by MacOS? If I change it to -rpath, a different intermediate error occurs which leads to the same ModuleNotFoundError though.
A different idea, has it something to do with that MacOs generates .dylib instead of .so files?
Any help is highly appreciated!
Thank you very much.
(.venv) user@computer pendulum_on_cart % python3 cython_example_closed_loop.py
make: *** No rule to make target `clean_all'. Stop.
cc -fPIC -std=c99 -O2 -I/path/to/acados/include -I/path/to/acados/include/acados -I/path/to/acados/include/blasfeo/include -I/path/to/acados/include/hpipm/include -c -o acados_solver_pendulum.o acados_solver_pendulum.c
cc -fPIC -std=c99 -O2 -I/path/to/acados/include -I/path/to/acados/include/acados -I/path/to/acados/include/blasfeo/include -I/path/to/acados/include/hpipm/include -c -o pendulum_model/pendulum_expl_ode_fun.o pendulum_model/pendulum_expl_ode_fun.c
cc -fPIC -std=c99 -O2 -I/path/to/acados/include -I/path/to/acados/include/acados -I/path/to/acados/include/blasfeo/include -I/path/to/acados/include/hpipm/include -c -o pendulum_model/pendulum_expl_vde_forw.o pendulum_model/pendulum_expl_vde_forw.c
cc -fPIC -std=c99 -O2 -I/path/to/acados/include -I/path/to/acados/include/acados -I/path/to/acados/include/blasfeo/include -I/path/to/acados/include/hpipm/include -c -o pendulum_model/pendulum_expl_vde_adj.o pendulum_model/pendulum_expl_vde_adj.c
cc -shared acados_solver_pendulum.o pendulum_model/pendulum_expl_ode_fun.o pendulum_model/pendulum_expl_vde_forw.o pendulum_model/pendulum_expl_vde_adj.o -o libacados_ocp_solver_pendulum.dylib -L/path/to/acados/lib -lacados -lhpipm -lblasfeo -lm \
-L -l
ld: warning: search path '-l' not found
cython \
-o acados_ocp_solver_pyx.c \
-I /path/to/acados/include/../interfaces/acados_template/acados_template \
/path/to/acados/include/../interfaces/acados_template/acados_template/acados_ocp_solver_pyx.pyx \
-I /path/to/acados/examples/acados_python/pendulum_on_cart/c_generated_code \
cc -c -O2 \
-fPIC \
-o acados_ocp_solver_pyx.o \
-I /path/to/acados/include/blasfeo/include/ \
-I /path/to/acados/include/hpipm/include/ \
-I /path/to/acados/include \
-I /path/to/.venv/lib/python3.10/site-packages/numpy/core/include \
-I /path/to/.pyenv/versions/3.10.11/include/python3.10 \
acados_ocp_solver_pyx.c \
In file included from acados_ocp_solver_pyx.c:1230:
In file included from /path/to/.venv/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5:
In file included from /path/to/.venv/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /path/to/.venv/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1929:
/path/to/.venv/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with " \
^
1 warning generated.
cc -shared \
-o acados_ocp_solver_pyx.dylib \
-Wl,-rpath=/path/to/acados/lib \
acados_ocp_solver_pyx.o \
/path/to/acados/examples/acados_python/pendulum_on_cart/c_generated_code/libacados_ocp_solver_pendulum.dylib \
-L/path/to/acados/lib -lacados -lhpipm -lblasfeo -lm
ld: unknown options: -rpath=/path/to/acados/lib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ocp_cython] Error 1
Traceback (most recent call last):
File "/path/to/acados/examples/acados_python/pendulum_on_cart/cython_example_closed_loop.py", line 145, in <module>
main()
File "/path/to/acados/examples/acados_python/pendulum_on_cart/cython_example_closed_loop.py", line 114, in main
acados_ocp_solver = AcadosOcpSolver.create_cython_solver(solver_json)
File "/path/to/acados/interfaces/acados_template/acados_template/acados_ocp_solver.py", line 177, in create_cython_solver
acados_ocp_solver_pyx = importlib.import_module(f'{os.path.split(code_export_directory)[1]}.acados_ocp_solver_pyx')
File "/path/to/.pyenv/versions/3.10.11/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'c_generated_code.acados_ocp_solver_pyx'