4 Installation

In this section we discuss how to install and setup the MOSEK Fusion 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 Fusion API for Python requires Python 3 with NumPy. The supported versions of Python are shown below:

Table 4.1 Supported Python versions.

Platform

Python

Linux 64 bit x86

3.7-3.12

Linux 64 bit ARM

3.7-3.12

macOS 64 bit x86

3.7-3.12

macOS 64 bit ARM

3.8-3.12

Windows 64 bit x86

3.7-3.12

4.1 PIP and Wheels

The recommended way to install MOSEK Optimization Suite is via PIP:

pip install Mosek --user

(skip --user for a system-wide installation).

If you installed the MOSEK package with PIP, no additional setup is required.

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

Table 4.2 Relevant files for the Fusion API for Python.

Relative Path

Description

Label

<MSKHOME>/mosek/10.2/tools/platform/<PLATFORM>/python/3

Python 3 install

<PYTHON3DIR>

<MSKHOME>/mosek/10.2/tools/examples/fusion/python

Examples

<EXDIR>

<MSKHOME>/mosek/10.2/tools/examples/fusion/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. win64x86, linux64x86 or osx64x86.

Manual install and setting up paths

You can install MOSEK for Python manually from the MOSEK distribution using pip. At least version 21.3 of pip is required, as it allows for in-tree builds. Go to the folder <MSKHOME>/mosek/10.2/tools/platform/<PLATFORM>/python/3 and run

pip install .

All standard options for pip can be applied according to the user’s needs.

4.4 Testing the Installation

First of all, to check that the Fusion 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