4 Installation¶
In this section we discuss how to install and setup the MOSEK Optimizer API for Python.
Important
Before running this MOSEK interface please make sure that you:
- Installed MOSEK correctly. Some operating systems require extra steps. See the Installation guide for instructions and common troubleshooting tips.
- Set up a license. See the Licensing guide for instructions.
Compatibility
The Optimizer API for Python requires Python with numpy. The supported versions of Python are shown below:
Platform Python PyPy Linux 64 bit 2.7, 3.6+ 2.7 Mac OS 64 bit 2.7, 3.6+ 2.7 Windows 32 and 64 bit 2.7, 3.6+ 2.7
4.1 Anaconda¶
The MOSEK Optimization Suite can be installed as an Anaconda package, see https://anaconda.org/MOSEK/mosek, for example by running
conda install -c mosek mosek
If you installed the MOSEK package as part of Anaconda, no additional setup is required.
4.2 PIP and Wheels¶
The MOSEK Optimization Suite can be installed as a Wheels package with PIP, using
pip install -f https://download.mosek.com/stable/wheel/index.html Mosek --user
(skip --user for a system-wide installation).
If you installed the MOSEK package with PIP, no additional setup is required.
4.3 PyPy¶
To use MOSEK in PyPy install the MOSEK Python module from the directory <PLATFORM>/purepython instead of <PLATFORM>/python as described below.
4.4 Manual installation¶
Locating files in the MOSEK Optimization Suite
The relevant files of the Optimizer API for Python are organized as reported in Table 4.1.
| Relative Path | Description | Label |
|---|---|---|
<MSKHOME>/mosek/9.0/tools/platform/<PLATFORM>/python/2 |
Python 2 install | <PYTHON2DIR> |
<MSKHOME>/mosek/9.0/tools/platform/<PLATFORM>/python/3 |
Python 3 install | <PYTHON3DIR> |
<MSKHOME>/mosek/9.0/tools/examples/python |
Examples | <EXDIR> |
<MSKHOME>/mosek/9.0/tools/examples/data |
Additional data | <MISCDIR> |
where
<MSKHOME>is the folder in which the MOSEK Optimization Suite has been installed,<PLATFORM>is the actual platform among those supported by MOSEK, i.e.win32x86,win64x86,linux64x86orosx64x86.
Manual install and setting up paths
To install MOSEK for Python run the <PYTHON2DIR>/setup.py or <PYTHON3DIR>/setup.py script depending on the Python version you want to use. This will add the MOSEK module to your Python distribution’s library of modules. The script accepts the standard options typical for Python setup scripts. For instance, to install MOSEK for Python 3 in the user’s local library run:
$ python3 <PYTHON3DIR>/setup.py install --user
on Linux and Mac OS or
C:\> python3 <PYTHON3DIR>\setup.py install --user
on Windows.
For a system-wide installation drop the --user flag.
4.5 Testing the Installation¶
First of all, to check that the Optimizer API for Python was properly installed, start Python and try
import mosek
The installation can further be tested by running some of the enclosed examples. Open a terminal, change folder to <EXDIR> and use Python to run a selected example, for instance:
python lo1.py