Install Guide

Mac OS X

The following instructions assume you already have Python installed. CVXPY supports both Python 2 and Python 3.

  1. Install the Command Line Tools for Xcode.

    Download from the Apple developer site.

  2. If you don’t have pip installed, follow the instructions here to install it.

  3. Install numpy with pip from the command-line.

    pip install numpy
    
  4. Install cvxpy with pip from the command-line.

    pip install cvxpy
    
  5. Test the installation with nose.

pip install nose
nosetests cvxpy

Ubuntu 14.04

The following instructions are for installing CVXPY with Python 2. To install CVXPY with Python 3, simply install the Python 3 version of all the packages.

  1. Make sure apt-get is up-to-date.
sudo apt-get update
  1. Install ATLAS and gfortran (needed for SCS).

    sudo apt-get install libatlas-base-dev gfortran
    
  2. Install python-dev.

    sudo apt-get install python-dev
    
  3. Install pip.

    sudo apt-get install python-pip
    
  4. Install numpy and scipy.

    sudo apt-get install python-numpy python-scipy
    
  5. Install cvxpy.

    sudo pip install cvxpy
    

or to install locally

pip install --user cvxpy
  1. Install nose.
sudo apt-get install python-nose
  1. Test the installation with nose.
nosetests cvxpy

Windows

Here is a step-by-step guide to installing CVXPY on a Windows machine.

  1. If you have Python installed already, it’s probably a good idea to remove it first. (Sorry!)
  2. Download the latest version of Python(x,y).
  3. Install Python(x,y). When prompted to select optional components, make sure to check cvxopt and cvxpy, as shown below.
../_images/windows1.png ../_images/windows2.png

4. To test the cvxpy installation, open Python(x,y) and launch the interactive console (highlighted button in the picture). This will bring up a console.

../_images/windows4.png

5. 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.

Install from source

CVXPY has the following dependencies:

To test the CVXPY installation, you additionally need Nose.

CVXPY automatically installs ECOS, CVXOPT, SCS, and toolz. NumPy and SciPy will need to be installed manually. Once you’ve installed NumPy and SciPy, installing CVXPY from source is simple:

  1. Clone the CVXPY git repository.

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

    python setup.py install
    

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 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 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.