Installing GNU Scientific Library (GSL) and CythonGSL in Windows
Table of Contents
I describe how to install GNU Scientific Library (GSL) for CythonGSL in Windows.
CythonGSL is a great module which expose functions of GNU Scientific Library (GSL) to Cython so you can use them in your Cython extension modules conveniently.
In GNU/Linux, you can install GSL library with development header files with a
one liner (for example, $ sudo zypper install gsl-devel
in openSUSE), but in
Windows it is a bit more involved, and if you are not familiar with these kind
of stuff (like me) it can take hours to figure out what is wrong. I hope this
post will save some time for others.
In sum, you need to do 1) download and unpack GSL with header files and right
architecture, 2) set LIB_GSL
environmental variable to the GSL directory,
and 3) add the path to the bin
subdirectory of the GSL directory to PATH
environmental variable.
1 Download
1.1 GSL
oscats project has the latest GSL Windows DLL and headers for both 32 and
64-bit. Make sure you download the one for the right architecture (the same
one as your Python installation). For example, gsl-1.15-dev-win64.zip
for
the 64-bit.
1.2 CythonGSL
If you use git, you can download CythonGSL with git clone
:
git clone git://github.com/twiecki/CythonGSL.git
or you can just download the zip archive of the master branch.
2 Installing GSL
Just extract the downloaded file to your preferred location such as
C:\lib64\GSL
or C:\Users\YourName\lib\GSL
. In general it is good idea to
not have any spaces in the path. From now on I will assume that you have
extracted the archive file into C:\lib64\GSL
, so if you extract it into
different location, change the path accordingly when you follow the
instructions below.
3 Environmental Variables
You need to add an environmental variable LIB_GSL
and also add the path of
\bin
subdirectory of your GSL installation to your PATH
Environmental
variable.
3.1 LIB_GSL
Create an environmental variable LIB_GSL
with the path to your GSL
installation. It is recommended to use Unix style path separator, /
instead of \
for this:
LIB_GSL=C:/lib64/GSL
3.2 PATH
Add C:\GSL\bin
to your PATH
environmental variable. This is so Windows can
find the two DLL files, libgsl-0.dll
and libgslcblas-0.dll
. Otherwise,
your Cython code will compile, but it will raise the following error at
runtime:
ImportError: DLL load failed: The specified module could not be found.
4 Installing CythonGSL
If you have done git clone
then just cd CythonGSL
and if you have downloaded
.zip
archive, extract it and go to the directory. Then, following the
official instructions,
python setup.py build
python setup.py install
Comments
Comments powered by Disqus