QuantLib-Python installation on Linux

Installation from PyPI (recommended)

If you don't need to modify the wrappers, you can install a precompiled wheel from PyPI. Once you have activated the Python environment you want to use, make sure you have the latest version of pip by running:

  python -m pip install -U pip

(note that your Python interpreter might be named python3 instead) and then run:

  python -m pip install QuantLib

If a wheel is available for your system (which is likely) it will be installed and you will be able to leave this page and use it right away; if not, you'll have to compile it yourself as described in the next section.

Installation from a released version

The following assumes that you already installed QuantLib; instructions are available at https://www.quantlib.org/install/linux.shtml

Setup

Before compiling the wrappers, you'll need to set up an appropriate environment:

Compilation

You can download released QuantLib-SWIG versions from GitHub at https://github.com/lballabio/QuantLib-SWIG/releases. You should download the same version as the version of QuantLib you installed; for the sake of example, I'll use version 1.36 which is the most recent version at the time of this writing.

Once you have the tarball, extract it by executing

  tar xzf QuantLib-SWIG-1.36.tar.gz
This creates a folder QuantLib-SWIG-1.36; enter it and configure QuantLib by executing:
  cd QuantLib-SWIG-1.36
  ./configure

After configuration, you can run

  cd Python
  make

This will create a binary wheel in the dist directory. To check that it works, run

  make check

from the Python directory (you should already be there).

Once you're done, you can take the wheel and install it with pip in the environment of your choice.

Installation from a git repository

If you want to compile from a checkout of a git repository (such as the official one at https://github.com/lballabio/quantlib-swig, or a fork of it that you might have created) you'll need an additional step at the beginning of the process. Before running the ./configure script, you'll have to create it by executing

  ./autogen.sh

To do this, you'll need automake, autoconf and libtool. Again, they're packaged for most Linux distributions; on Ubuntu, you would get them by running

  sudo apt-get install automake autoconf libtool

After the execution of ./autogen.sh, the installation proceeds as in the previous section. Note, though, that in this case you'll need SWIG available; you can download and install it from http://swig.org. At the time of this writing, the wrappers use SWIG 4.3.0.