QuantLib-Python installation on Mac OS X
The following assumes that you already installed QuantLib. Instructions for that are available at http://quantlib.org/install/macosx.shtml. In particular, check that you have provided the required options and environment variables to ./configure.
Installation from a released version
You can download released QuantLib-SWIG versions from the SourceForge download page
at http://sourceforge.net/projects/quantlib/files/; look for the files under the
other languages folder in any of the versioned folders under
Once you have the tarball, extract it by executing:
tar xzf QuantLib-SWIG-1.8.tar.gz
(1.8 is the most recent version at the time of this writing; you
might have downloaded another one, but take care to use one compatible
with the version of QuantLib you installed.) This creates a
QuantLib-SWIG-1.8; enter it and configure QuantLib
On Mac OS X 10.11 (El Capitan) and later,
cd QuantLib-SWIG-1.8 ./configure CXXFLAGS='-O2 -stdlib=libc++ -mmacosx-version-min=10.9'
On Mac OS X 10.9 (Mavericks) and 10.10 (Yosemite),
cd QuantLib-SWIG-1.8 ./configure CXXFLAGS='-O2 -stdlib=libstdc++ -mmacosx-version-min=10.6'
On earlier systems,
cd QuantLib-SWIG-1.8 ./configure CXXFLAGS='-O2'
Contrary to popular belief, working from a released tarball doesn't require you to have SWIG installed. After configuration, you can run
make -C Python sudo make -C Python install
There are a couple of caveats to the above. The first is that
./configure command will need to
quantlib-config (which was installed with
QuantLib) to find out what flags should be passed to the compiler and
linker; they will also include the additional include directories you
might have specified when you built QuantLib, so you'll be covered
even if you have, say, Boost in a non-standard place. This means
quantlib-config must be in your path. If you
installed QuantLib in /usr/local like Homebrew or in /opt/local like
MacPorts, you should be already set up.
The second is that, unfortunately, at this time
install ignores any prefix you might pass
./configure and always installs to the default
location, which requires you to use
sudo as I wrote
above. If you don't have admin rights, or if you want to install to a
different location (for instance, an Anaconda virtualenv) you can run:
cd Python python setup.py install --prefix=/your/desired/location cd ..replacing /your/desired/location with the actual path where you want to install (if the path is protected, you might still need to use sudo to run the command).
Once you're done, you can try to run a few examples to check your installation. To do this, you can execute:
make -C Python check
Installation from a git repository
If you want to compile from a checkout of a git repository (such as
the official one
or a fork of it that you might have created) you'll need an additional
step at the beginning of the process. Before running
./configure script, you'll have to create it by
To do this, you'll need automake, autoconf and libtool. They can be installed using either Homebrew or MacPorts.
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 or, again, get it
packaged from Homebrew or MacPorts.