4. Testing installation and Running examples


This chapter describes how to verify that the MOSEK Python API has been installed and works, and how to run the distributed examples.

The MOSEK Python interface requires a MOSEK installation, a full Python installation and the Numerical Python extension. A Python installer can be obtained from the official site

http://www.python.org/

or packaged from

http://www.activestate.com/Products/ActivePython/

The Numeric extension providing arrays and mathematical functionality can be obtained from

http://numeric.scipy.org/

This package is not required, but the MOSEK Python API can use Numeric arrays more efficiently than generic arrays or lists. The Numerical package is expected to be replaced by NumPy in the near future.

4.1. Microsoft Windows Platform

To use the MOSEK Python interface, a working MOSEK installation must be present — see the MOSEK Installation manual for instructions. In the following we assume that assume that MOSEK is installed in the default directory

C:\Program Files\mosek

Please note that this may be different for other language settings than US English. The MOSEK Python interface is defined in

C:\Program Files\mosek\5\tools\platform\win\bin\pymosek.pyd

or

C:\Program Files\mosek\5\tools\platform\win64\bin\pymosek.pyd

depending on the platform.

The distributed Python examples are found in

C:\Program Files\mosek\5\tools\examples\python

4.1.1. Running an example

To run one of the distributed examples, open a DOS box and type

C:
cd "\Program Files\mosek\5\tools\examples\python"

then to execute example lo1 type

python lo1.py

4.2. Linux Platform

MOSEK can be installed by unzipping it to some directory — the complete procedure is described in the MOSEK Installation manual for instructions. In the following we assume that assume that MOSEK was unzipped to the user's home directory, and that all steps in the installation was completed.

The MOSEK Python API is defined in the library

pymosek.so

in one of the directories

~/mosek/5/tools/platform/linux32x86/bin/pymosek.so
~/mosek/5/tools/platform/linux64x86/bin/pymosek.so

depending on the platform. All other required libraries reside in the same directory as this module.

The distributed Python examples are found in

C:/mosek/5/tools/examples/python

Before the MOSEK Python API can be used, the system environment must be set correctly up:

You can verify that this is the case as follows: Open a shell and type

  echo $PATH

This prints a “:”-separated list of paths which should contain the path to MOSEK. Then type

  echo $PYTHONPATH

This prints a “:”-separated list of paths which should contain the path to pymosek.so. If one of the above were missing, they must be set up. This can be done either temporarily or permanently:

4.2.1. Executing a Python program

To run a Python script, open a shell, change directory to where the script is located, and type

python myscript.py

where myscript.py is the name of the Python script.

Mon Sep 14 15:53:06 2009