Building from sources#
Note
If you are only trying to install SciPy, see Installation.
Build instructions for different operating systems and an FAQ.
System-level dependencies#
SciPy uses compiled code for speed, which means you might need extra dependencies to build it on your system.
Note
You can skip these steps if you are using conda
, as these dependencies
will be installed automatically.
If you want to use the system Python and pip
, you will need:
C, C++, and Fortran compilers (typically
gcc
,g++
, andgfortran
).Python header files (typically a package named
python3-dev
orpython3-devel
)BLAS and LAPACK libraries. OpenBLAS is the SciPy default; other variants include ATLAS and MKL.
Note
These instructions have been tested on Ubuntu Linux 16.04, 18.04, and 20.04.
Python should be available in your system via the python3
command. To
install the remaining system-level dependencies, run:
sudo apt install -y gcc g++ gfortran libopenblas-dev liblapack-dev pkg-config
sudo apt install -y python3-pip python3-dev
Alternatively, you can do:
sudo apt build-dep scipy
This command installs whatever is needed to build SciPy, with the advantage that new dependencies or updates to required versions are handled by the package managers.
See also Development environment guide (Ubuntu).
To install SciPy build requirements, you can do:
sudo dnf install gcc-gfortran python3-devel openblas-devel lapack-devel
Alternatively, you can do:
sudo dnf builddep scipy
This command installs whatever is needed to build SciPy, with the advantage that new dependencies or updates to required versions are handled by the package managers.
To install SciPy build requirements, you can do:
sudo yum install gcc-gfortran python3-devel openblas-devel lapack-devel
Alternatively, you can do:
sudo yum-builddep scipy
This command installs whatever is needed to build SciPy, with the advantage that new dependencies or updates to required versions are handled by the package managers.
To install SciPy build requirements, you can do:
sudo pacman -S gcc-fortran openblas
All further work should proceed in a virtual environment. Popular options
include the standard library venv
module or a separate virtualenv
package.
The Cython and Pythran ahead-of-time compilers are also necessary, as is
pybind11
. It is recommended to install these packages withpip
, because it is possible (even likely) that you need newer versions of these packages than the ones that are available in your Linux distribution.
If you are using conda, these dependencies can be installed in the conda environment itself. See Development environment guide (conda) for more details.
Install Apple Developer Tools. An easy way to do this is to open a terminal window, enter the command
xcode-select --install
and follow the prompts. Apple Developer Tools includes git, the software we need to download and manage the SciPy source code. See also Building from source on Mac.
Detailed instructions#
Reference for build options#
SciPy has several tunable build-time options, which can be set.
Warning
This content is for the old numpy.distutils-based build and doesn’t apply
to the Meson build (i.e., when building with python dev.py
).
site.cfg
: build-time library configuration file, seesite.cfg.example
for details.Environment variables
NPY_LAPACK_ORDER
,NPY_BLAS_ORDER
,OPENBLAS
,ATLAS
, etc., also controlling library configuration. See Numpy documentation for more details.Environment variable
NPY_USE_BLAS_ILP64=1
: build using 64-bit integer size (ILP64) BLAS+LAPACK libraries.Note that even when this is set, SciPy requires also 32-bit integer size (LP64) BLAS+LAPACK libraries to be available and configured. This is because only some components in SciPy make use of the 64-bit capabilities.