Python wrapper for selected SLICOT routines, notably including solvers for Riccati, Lyapunov, and Sylvester equations.
Slycot supports Python versions 2.7, and 3.5 or later.
To run the compiled Slycot package, the following must be installed as dependencies:
- Python 2.7, 3.5+
If you are compiling and installing Slycot from source, you will need the following dependencies:
- Python 2.7, 3.5+
- scikit-build >= 0.10.0
- C compiler (e.g. gcc, MS Visual C++)
- FORTRAN compiler (e.g. gfortran, ifort, flang)
- BLAS/LAPACK (e.g. OpenBLAS, ATLAS, MKL)
To run the Slycot unit tests and examples, you'll also need scipy and pytest.
There are a variety of ways to install these dependencies on different operating systems. See the individual packages' documentation for options.
The easiest way to get started with Slycot is to install pre-compiled binaries from conda-forge (see below); these are available for Linux, OSX, and Windows.
Compiling the Slycot source is unfortunately a bit tricky, especially on Windows, but we give some pointers further below for doing this.
Using conda and conda-forge
First install Miniconda or Anaconda. Slycot can then be installed from the conda-forge channel with the following command:
conda install -c conda-forge slycot
From source without conda (Linux, macOS, Windows)
Unpack the source code to a directory of your choice,
If you need to specify a specific compiler, set the environment variable FC before running the install:
# Linux/OSX: export FC=/path/to/my/fortran # Windows: set FC=D:\path\to\my\fortran.exe
To build and install, execute:
cd /path/to/slycot_src/ python setup.py install
From source using a conda recipe (Linux and macOS)
You can also use conda to build and install Slycot from source, but you'll have to choose the right recipe directory.
On Linux you can choose between
On macOS you should use
conda-recipe-apple. See the
conda-build documentation how to get the required macOS SDK.
For example, to build with the OpenBLAS recipe:
conda build -c conda-forge conda-recipe-openblas conda install -c conda-forge --use-local slycot
From source in a conda environment (Windows)
A similar method can be used for Linux and macOS, but is detailed here for Windows. This method uses conda and conda-forge to get most build dependencies, except for the C compiler.
This procedure has been tested on Python 3.7 and 3.8.
First, install the correct Visual Studio compiler for the Python version you wish to build for.
In such a command shell, run the following commands to build and install Slycot (this example creates a Python 3.8 environment):
conda create --channel conda-forge --name build-slycot python=3.8 numpy scipy libblas=*=*netlib liblapack=*=*netlib scikit-build flang pytest conda activate build-slycot python setup.py install
To test if the installation was successful, you can run the slycot unit tests:
pytest --pyargs slycot
You may also run the tests by calling
slycot.test() from within the python
import slycot slycot.test()
slycot or running
--pyargs slycot from
inside the source directory will fail, unless the compiled wrapper library has
been installed into that directory. Note that the
setup.cfg enforces the
--pyargs slycot argument by default.
General notes on compiling
Additional tips for how to install Slycot from source can be found in the
.travis.yml (commands used for Travis CI) and the
directories (conda pre-requisites) both which are included in the source
The hardest part about installing from source is getting a working version of FORTRAN and LAPACK (provided by OpenBLAS, MKL, etc.) installed on your system, and working properly with Python.
Note that in some cases you may need to set the
variable to pick up dependencies such as
-lpythonN.m (where N.m is the
version of python you are using).
We publish Slycot to the Python package index, but only as a source package, so to install using pip you'll first need to install the build prerequisites (compilers, libraries, etc.)
If you have these build prerequisites, install in the standard way with:
pip install slycot