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 and Linux

CVXPY supports both Python 2 and Python 3 on OS X and Linux. We recommend using Anaconda for installation, as we find that most users prefer to let Anaconda manage dependencies and environments for them. If you are comfortable with managing your own environment, you can instead install CVXPY with pip.

  1. Install Anaconda.

  2. Install cvxpy with conda.

    conda install -c conda-forge lapack
    conda install -c cvxgrp cvxpy
    
  3. Test the installation with nose.

conda install nose
nosetests cvxpy

Windows

CVXPY supports Python 2 (with Anaconda and pip) and Python 3 (with pip) on Windows. We recommend using Anaconda for installation, as we find that most users prefer to let Anaconda manage dependencies and environments for them. If you are comfortable with managing your own environment or need Python 3, you can instead install CVXPY with pip.

  1. Download and install the latest version of Anaconda.
  2. Download the Visual Studio C++ compiler for Python.
  3. Install CVXPY from the Anaconda prompt by running the following command:
conda install -c conda-forge lapack
conda install -c cvxgrp cvxpy

4. From the console, run nosetests cvxpy. If all the tests pass, your installation was successful.

Other Platforms

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

Pip

CVXPY can be installed on all platforms with pip. We recommend isolating your installation in a virtualenv. After activating the environment, simply execute:

pip install 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 support

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

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 GLPK support

CVXPY supports the GLPK solver, but only if CVXOPT is installed with GLPK bindings. 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 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.