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 3. The supported versions of Python are shown below:
Platform |
Python |
---|---|
Linux 64 bit x86 |
3.6+ |
Linux 64 bit ARM |
3.7+ |
macOS 64 bit x86 |
3.6+ |
macOS 64 bit ARM |
3.8+ |
Windows 64 bit x86 |
3.6+ |
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 Mosek --user
(skip --user
for a system-wide installation).
If you installed the MOSEK package with PIP, no additional setup is required.
4.3 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.2.
Relative Path |
Description |
Label |
---|---|---|
|
Python 3 install |
|
|
Examples |
|
|
Additional data |
|
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
orosx64x86
.
Manual install and setting up paths
To install MOSEK for Python run the <PYTHON3DIR>/setup.py
script. 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 in the user’s local library run:
$ python <PYTHON3DIR>/setup.py install --user
on Linux and macOS or
C:\> python <PYTHON3DIR>\setup.py install --user
on Windows.
For a system-wide installation drop the --user
flag.
4.4 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
4.5 Troubleshooting¶
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