Fetching contributors…
Cannot retrieve contributors at this time
375 lines (249 sloc) 10.4 KB
Building and installing SciPy
for updates of this document.
.. Contents::
It is *strongly* recommended that you use the binary packages on your platform
if they are available, in particular on Windows and Mac OS X. You should not
attempt to build SciPy if you are not familiar with compiling softwares from
SciPy requires the following software installed for your platform:
1) Python__ 2.4.x or newer
2) NumPy__ 1.4.1 or newer (note: SciPy trunk at times requires latest NumPy
It is recommended to use the mingw__ compilers on Windows: you will need gcc
(C), g++ (C++) and g77 (Fortran) compilers.
Blas/Lapack are core routines for linear algebra (vector/matrix operations).
You should use ATLAS__ with a full LAPACK, or simple BLAS/LAPACK built with g77
from netlib__ sources. Building those libraries on windows may be difficult, as
they assume a unix-style environment. Please use the binaries if you don't feel
comfortable with cygwin, make and similar tools.
Mac OS X
It is recommended to use gcc. gcc is available for free when installing
Xcode__, the developer toolsuite on Mac OS X. You also need a fortran compiler,
which is not included with Xcode: you should use gfortran from this page:
Please do NOT use gfortran from, it is known to generate
buggy scipy binaries.
Mac OS X includes the Accelerate framework: it should be detected without any
intervention when building SciPy.
Most common distributions include all the dependencies. Here are some
instructions for the most common ones:
Ubuntu >= 8.10
You can get all the dependencies as follows::
sudo apt-get install python python-dev libatlas3-base-dev gcc gfortran g++
Ubuntu < 8.10, Debian
You can get all the dependencies as follows::
sudo apt-get install python python-dev atlas3-base-dev gcc g77 g++
OpenSuse >= 10
Fedora Core
For the latest information, see the web site:
Development version from Subversion (SVN)
Use the command::
svn co scipy
Before building and installing from SVN, remove the old installation
(e.g. in /usr/lib/python2.4/site-packages/scipy or
$HOME/lib/python2.4/site-packages/scipy). Then type::
cd scipy
rm -rf build
python install
First make sure that all SciPy prerequisites are installed and working
properly. Then be sure to remove any old SciPy installations (e.g.
/usr/lib/python2.4/site-packages/scipy or $HOME/lib/python2.4/
site-packages/scipy). On windows, if you installed scipy previously from a
binary, use the remove facility from the add/remove softwares panel, or remote
the scipy directory by hand if you installed from sources (e.g.
C:\Python24\Lib\site-packages\scipy for python 2.4).
From tarballs
Unpack ``SciPy-<version>.tar.gz``, change to the ``SciPy-<version>/``
directory, and run
python install
This may take several minutes to an hour depending on the speed of your
computer. To install to a user-specific location instead, run::
python install --prefix=$MYDIR
where $MYDIR is, for example, $HOME or $HOME/usr.
** Note 1: On Unix, you should avoid installing in /usr, but rather in
/usr/local or somewhere else. /usr is generally 'owned' by your package
manager, and you may overwrite a packaged scipy this way.
To test SciPy after installation (highly recommended), execute in Python
>>> import scipy
>>> scipy.test()
To run the full test suite use
>>> scipy.test('full')
Please note that you must have version 0.10 or later of the 'nose' test
framework installed in order to run the tests. More information about nose is
available on the website__.
Note that SciPy is developed mainly using GNU compilers. Compilers from
other vendors such as Intel, Absoft, Sun, NAG, Compaq, Vast, Porland,
Lahey, HP, IBM are supported in the form of community feedback.
gcc__ compiler is recommended. gcc 3.x and 4.x are known to work.
If building on OS X, you should use the provided gcc by xcode tools, and the
gfortran compiler available here:
You can specify which Fortran compiler to use by using the following
install command::
python config_fc --fcompiler=<Vendor> install
To see a valid list of <Vendor> names, run::
python config_fc --help-fcompiler
IMPORTANT: It is highly recommended that all libraries that scipy uses (e.g.
blas and atlas libraries) are built with the same Fortran compiler. In most
cases, if you mix compilers, you will not be able to import scipy at best, have
crashes and random results at worse.
Using non-GNU Fortran compiler with gcc/g77 compiled Atlas/Lapack libraries
When Atlas/Lapack libraries are compiled with GNU compilers but
one wishes to build scipy with some non-GNU Fortran compiler then
linking extension modules may require -lg2c. You can specify it
in installation command line as follows::
python build build_ext -lg2c install
If using non-GNU C compiler or linker, the location of g2c library can
be specified in a similar manner using -L/path/to/libg2c.a after
build_ext command.
Intel Fortran Compiler
Note that code compiled by the Intel Fortran Compiler (IFC) is not
binary compatible with code compiled by g77. Therefore, when using IFC,
all Fortran codes used in SciPy must be compiled with IFC. This also
includes the LAPACK, BLAS, and ATLAS libraries. Using GCC for compiling
C code is OK. IFC version 5.0 is not supported (because it has bugs that
cause SciPy's tests to segfault).
Minimum IFC flags for building LAPACK and ATLAS are
-FI -w90 -w95 -cm -O3 -unroll
Also consult 'ifc -help' for additional optimization flags suitable
for your computers CPU.
When finishing LAPACK build, you must recompile ?lamch.f, xerbla.f
with optimization disabled (otherwise infinite loops occur when using
these routines)::
make lapacklib # in /path/to/src/LAPACK/
cd SRC
ifc -FI -w90 -w95 -cm -O0 -c ?lamch.f xerbla.f
cd ..
make lapacklib
BLAS sources shipped with LAPACK are incomplete
Some distributions (e.g. Redhat Linux 7.1) provide BLAS libraries that
are built from such incomplete sources and therefore cause import
errors like
ImportError: .../ undefined symbol: srotmg_
Use ATLAS or the official release of BLAS libraries.
LAPACK library provided by ATLAS is incomplete
You will notice it when getting import errors like
ImportError: .../ : undefined symbol: sgesdd_
To be sure that SciPy is built against a complete LAPACK, check the
size of the file liblapack.a -- it should be about 6MB. The location
of liblapack.a is shown by executing
python /lib/python2.4/site-packages/numpy/distutils/
(or the appropriate installation directory).
To fix: follow the instructions in
to create a complete liblapack.a. Then copy liblapack.a to the same
location where libatlas.a is installed and retry with scipy build.
Using non-GNU Fortran Compiler
If import scipy shows a message
ImportError: undefined symbol: s_wsfe
and you are using non-GNU Fortran compiler, then it means that any of
the (may be system provided) Fortran libraries such as LAPACK or BLAS
were compiled with g77. See also compilers notes above.
Recommended fix: Recompile all Fortran libraries with the same Fortran
compiler and rebuild/reinstall scipy.
Another fix: See `Using non-GNU Fortran compiler with gcc/g77 compiled
Atlas/Lapack libraries` section above.
If you experience problems when building/installing/testing SciPy, you
can ask help from or mailing
lists. Please include the following information in your message:
NOTE: You can generate some of the following information (items 1-5,7)
in one command::
python -c 'from numpy.f2py.diagnose import run; run()'
1) Platform information::
python -c 'import os,sys;print,sys.platform'
uname -a
OS, its distribution name and version information
2) Information about C,C++,Fortran compilers/linkers as reported by
the compilers when requesting their version information, e.g.,
the output of
gcc -v
g77 --version
3) Python version::
python -c 'import sys;print sys.version'
4) NumPy version::
python -c 'import numpy;print numpy.__version__'
5) ATLAS version, the locations of atlas and lapack libraries, building
information if any. If you have ATLAS version 3.3.6 or newer, then
give the output of the last command in
cd scipy/Lib/linalg
python build_ext --inplace --force
python -c 'import atlas_version'
7) The output of the following commands
python INSTALLDIR/numpy/distutils/
where INSTALLDIR is, for example, /usr/lib/python2.4/site-packages/.
8) Feel free to add any other relevant information.
For example, the full output (both stdout and stderr) of the SciPy
installation command can be very helpful. Since this output can be
rather large, ask before sending it into the mailing list (or
better yet, to one of the developers, if asked).
9) In case of failing to import extension modules, the output of
ldd /path/to/
can be useful.
You may find the following notes useful: