In this section we discuss how to install and setup the MOSEK Fusion API for Python.
Before running this MOSEK interface please make sure that you:
The Fusion API for Python requires Python with numpy. The supported versions of Python are shown below:
|Linux 64 bit||2.7, 3.6, 3.7, 3.8, 3.9||2.7|
|Mac OS 64 bit||2.7, 3.6, 3.7, 3.8, 3.9||2.7|
|Windows 64 bit||2.7, 3.6, 3.7, 3.8, 3.9||2.7|
|Windows 32 bit||2.7, 3.6, 3.7||2.7|
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 Mosek --user
--user for a system-wide installation).
If you installed the MOSEK package with PIP, no additional setup is required.
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 Fusion API for Python are organized as reported in Table 4.2.
||Python 2 install||
||Python 3 install||
<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.
Manual install and setting up paths
To install MOSEK for Python run the
<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
For a system-wide installation drop the
4.5 Testing the Installation¶
First of all, to check that the Fusion API for Python was properly installed, start Python and try
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:
error: could not create ‘build’: Access is denied
If an attempt to install the Python interface results in an error such as
error: could not create 'build': Access is denied
then you have no write permissions to the folder where MOSEK is installed. This can happen for example if the package was installed by an administrator, and a user is trying to set up the Python interface. One solution is to install MOSEK in another location. Another solution is to specify the location of the build folder in a place the user can write to, for example:
python setup.py build --build-base=SOME_FOLDER install --user