[Python] How to properly configure IPOPT solver in Python virtual environment with CasADi?

Discussão em 'Python' iniciado por Stack, Abril 21, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a Python project using CasADi with IPOPT solver, but encountering a shared library loading error. Here's my setup:

    my_project/
    │
    ├── venv/
    │ ├── Includes
    │ ├── Lib
    │ └── Scripts
    │
    ├── src/
    │ ├── codes.py
    │ └── ...
    │
    ├── main.py
    │
    └── ...


    Casadi has been installed in Lib/site-packages, and libcasadi_nlpsol_ipopt.dll and libcasadi_nlpsol_ipopt.dll.a is also included.

    However, when running this basic IPOPT example in main.py:

    opti = ca.Opti()
    x = opti.variable()
    opti.minimize(x**2)
    opti.solver("ipopt", opts)
    sol = opti.solve()


    I get the following error: "WARNING(".../casadi/core/casadi_os.cpp:166: Assertion "handle!=nullptr" failed: PluginInterface::load_plugin: Cannot load shared library 'libcasadi_nlpsol_ipopt.dll'"

    How can I properly configure IPOPT in my virtual environment to resolve this shared library loading issue?

    Continue reading...

Compartilhe esta Página