Clone this wiki locally
Option 1: Binary installation (recommended)
Grab a binary from the table:
|Windows 64 bit||Linux (14.04+)||Mac|
|Matlab||R2014b or later||R2014b or later||R2015a or later|
|R2014a or later||R2014a or later||R2014b or later|
|R2013a or later||R2014a or later|
|Python||Py27 (py 32bit or py 64bit )||Py27||Py27|
|Py35 (py 32bit or py 64bit )||Py35||Py35|
or see download page for more options/versions ...
Unzip in your home directory and adapt the path:
addpath('.../casadi-matlabR2014a-v3.1.1') import casadi.* x = MX.sym('x') disp(jacobian(sin(x),x))
from sys import path path.append(r".../casadi-py27-np1.9.1-v3.1.1") from casadi import * x = MX.sym("x") print(jacobian(sin(x),x))
Get started with the example pack.
What follows are more detailed install instructions.
If you have installed a release of CasADi older than 2.3.0, it is highly recommended to remove it first: use the "remove installed programs" functionality on Windows, or
sudo dpkg --remove python-casadiin Linux, and follow the instructions below. Versions later than 2.3.0 can happily coexist.
The binaries include the solvers that are distributed with the tool (Sundials, qpOASES, CSparse) as well as IPOPT (shipped with the MUMPS linear solver; HSL is available through IPOPT's dynamic loader).
Some plugins require extra prerequisites to work on Linux. You can deal with them after you get basic CasADi up and running.
On our download page, locate and download the binary archive of your choice:
Note: the Windows binaries are all for 64-bit systems. The default binary is for a 32-bit python installation on the 64-bit system (like the one provided by
python-(x,y)). There is a variant with "-64" appended to the name for a 64-bit Python installation. Note: some binaries have "-Debug" appended to their names. These run slower, but have debugging info included.
Simply extract the archive such that a folder with the same name as the archive is created.
We will refer to this folder as
casadiinstalldir. It may be e.g. "C:\Downloads\casadi-py27-np1.9.1-v3.1.0" in your case.
Note: some users have reported problems when CasADi is put in the 'toolbox' directory of Matlab itself (errors like:
NewPointerObj problem. creating SwigRef as opposed to casadi.DM). Better not do that, just put in your home.
You can immediately test out the installation:
import sys sys.path.append(r"casadiinstalldir") from casadi import * x = MX.sym("x") print jacobian(sin(x),x)
addpath('casadiinstalldir') import casadi.* x = MX.sym('x') jacobian(sin(x),x)
Please contact us if this mechanism fails for you, or if you wish to see support for other versions.
To make the installation more permanent:
casadiinstalldir to the PYTHONPATH environmental variable
This is system dependent. On Linux/Mac, you would typically add a line like the following to your
.bashrc (for Mac
.profile) file in the home directory:
On Windows, you go to explorer, right click my computer, choose
advanced options and select
To help you get started, you can download the example pack.
Option 2: Build from sources
CasADi is written in self-contained C++, making heavy use of the C++ standard library, thus requiring nothing but a reasonably recent C++ compiler (with support for C++11). To build the code, we use CMake, version 2.8. The Python front-end requires SWIG (version 2.0 or newer). It has been written for Python 2.7, but has also been tested successfully on earlier Python 2.5 and 2.6. We show below how to get these dependencies and then to compile CasADi from sources.
Instructions on how to compile CasADi from sources:
For the Matlab front-end there are generic compile instruction at the Matlab page.
Option 3: CasADi on Conda
A build of CasADi-Python is available for the Conda environment in Linux and Mac (currently no Windows support).
conda config --add channels conda-forge conda install casadi
You should then be able to load up python and
import casadi with no problems. If you get errors and don't have a recent conda install, try a
conda update conda. Builds are available for Python 2.7, 3.5, and 3.6, and numpy 1.12. The build contains the IPOPT interface, but not any other third-party solvers.
For error reports relating to the conda install, we refer to conda-forge/casadi-feedstock. Thanks to Peter St. John for this contribution.