Install

Note: Version 1.0 of CVXPY is incompatible with previous versions in minor ways. See What’s New in 1.0 for how to update legacy code to a form that’s compatible with 1.0.

Mac OS X, Windows, and Linux

CVXPY supports both Python 2 and Python 3 on OS X, Windows, and Linux. We recommend using pip for installation. You may want to isolate your installation in a virtualenv. If you prefer Anaconda to pip, see the Anaconda installation guide.

  1. (Windows only) Download the Visual Studio C++ compiler for Python.
  2. Install cvxpy.
pip install cvxpy
  1. Test the installation with nose.
pip install nose
nosetests cvxpy

Other Platforms

The CVXPY installation process on other platforms is less automated and less well tested. Check this page for instructions for your platform.

Anaconda

Anaconda is an alternative to pip that combines package and environment management.

  1. Install Anaconda.

  2. (Windows only) Download the Visual Studio C++ compiler for Python.

  3. Install cvxpy with conda.

    conda config --add channels oxfordcontrol
    conda install -c cvxgrp cvxpy
    
  4. Test the installation with nose.

conda install nose
nosetests cvxpy

Install from source

CVXPY has the following dependencies:

To test the CVXPY installation, you additionally need Nose.

CVXPY automatically installs OSQP, ECOS, SCS, six, fastcache, and multiprocess. NumPy and SciPy will need to be installed manually, as will Swig . Once you’ve installed these dependencies:

  1. Clone the CVXPY git repository.

  2. Navigate to the top-level of the cloned directory and run

    python setup.py install
    

Install with CVXOPT and GLPK support

CVXPY supports the CVXOPT solver. Additionally, through CVXOPT, CVXPY supports the GLPK solver. On most platforms, CVXOPT comes with GLPK bundled. On such platforms, installing CVXPY with

pip install cvxpy[glpk]

should suffice to get support for both CVXOPT and GLPK.

On other platforms, to install CVXPY and its dependencies with GLPK support, follow these instructions:

  1. Install GLPK. We recommend either installing the latest GLPK from source or using a package manager such as apt-get on Ubuntu and homebrew on OS X.

  2. Install CVXOPT with GLPK bindings.

    CVXOPT_BUILD_GLPK=1
    CVXOPT_GLPK_LIB_DIR=/path/to/glpk-X.X/lib
    CVXOPT_GLPK_INC_DIR=/path/to/glpk-X.X/include
    pip install cvxopt
    
  3. Follow the standard installation procedure to install CVXPY and its remaining dependencies.

Install with Elemental support

CVXPY supports the Elemental solver. Simply install Elemental such that you can import El in Python. See the Elemental website for installation instructions.

Install with GUROBI support

CVXPY supports the GUROBI solver. Simply install GUROBI such that you can import gurobipy in Python. See the GUROBI website for installation instructions.

Install with MOSEK support

CVXPY supports the MOSEK solver. Simply install MOSEK such that you can import mosek in Python. See the MOSEK website for installation instructions.

Install with XPRESS support

CVXPY supports the XPRESS solver. Simply install XPRESS such that you can import xpress in Python. See the XPRESS website for installation instructions.

Install with Cbc (Clp, Cgl) support

CVXPY supports the Cbc solver (which includes Clp and Cgl) with the help of cylp. Simply install cylp (you will need the Cbc sources which includes Cgl) such you can import this library in Python. See the cylp documentation for installation instructions.

Install with CPLEX support

CVXPY supports the CPLEX solver. Simply install CPLEX such that you can import cplex in Python. See the CPLEX website for installation instructions.

Install with SDPT3 support

The sdpt3glue package allows you to model problems with CVXPY and solve them with SDPT3.