QuantLib-Python installation on Windows

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 for that are available at http://quantlib.org/install/vc10.shtml. Note that QuantLib must be compiled in Release mode, most likely in the x64 variant.

Setup

Before compiling the wrappers, you'll need to set up an appropriate environment. All of the following must be done in a command shell:

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 zip file, extract it by executing

  tar xzf QuantLib-SWIG-1.36.tar.gz
This creates a folder QuantLib-SWIG-1.36; enter its Python subfolder and build the QuantLib wrappers by executing:
  cd QuantLib-SWIG-1.36\Python
  python -m build wheel

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

  tox run

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. 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. Once SWIG is built and available in your path, run:

  swig -python -c++ -outdir src\QuantLib -o src\QuantLib\quantlib_wrap.cpp ..\SWIG\quantlib.i
from the QuantLib-SWIG-1.36\Python directory. The rest of the installation goes as above.