161

I'm trying to create required libraries in a package I'm distributing. It requires both the SciPy and NumPy libraries. While developing, I installed both using

apt-get install scipy

which installed SciPy 0.9.0 and NumPy 1.5.1, and it worked fine.

I would like to do the same using pip install - in order to be able to specify dependencies in a setup.py of my own package.

The problem is, when I try:

pip install 'numpy==1.5.1'

it works fine.

But then

pip install 'scipy==0.9.0'

fails miserably, with

raise self.notfounderror(self.notfounderror.__doc__)

numpy.distutils.system_info.BlasNotFoundError:

Blas (http://www.netlib.org/blas/) libraries not found.

Directories to search for the libraries can be specified in the

numpy/distutils/site.cfg file (section [blas]) or by setting

the BLAS environment variable.

How do I get it to work?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
eran
  • 14,496
  • 34
  • 98
  • 144
  • Hmm, Are you sure pip works well with `numpy=1.5.1` instead of `numpy==1.5.1` (double equals)? – Hugo Lopes Tavares Jun 21 '12 at 16:55
  • I'm using double equals, that was a typo. I just typed it in here instead of copy paste :) – eran Jun 24 '12 at 06:15
  • 5
    Apart from blas and lapack you need to install `blas-devel` and `lapack-devel`. This is not specified in the doc, but must be done if you want to install using PIP. – Iñigo Hernáez Corres Jun 12 '13 at 07:43
  • @IñigoHernáezCorres (blas-devel and lapack-devel) are also YUMable, I've learned, for those of us on amazon-linux. – Tommy May 10 '15 at 18:04
  • http://stackoverflow.com/questions/7496547/does-python-scipy-need-blas has the 2 steps in sequence – mhn Feb 29 '16 at 07:06
  • I just did this. Windows users can see my answer [here](http://stackoverflow.com/questions/1517129/how-do-i-install-scipy-on-64-bit-windows/40275240#40275240) – Statham Oct 27 '16 at 03:43
  • The accepted answer here has effectively rotted away due to link breakage (and looks to me like it never properly answered your question in the first place); would you consider unaccepting it so that the much more popular answer by vk1011 can rise to the top of the answer list? – Mark Amery May 11 '18 at 13:30
  • another related question (windows) https://stackoverflow.com/q/28413824 – djvg Apr 06 '21 at 14:24

8 Answers8

333

This worked for me on Ubuntu 14.04:

sudo apt-get install libblas-dev liblapack-dev libatlas-base-dev gfortran
pip install scipy
vk1011
  • 7,011
  • 6
  • 26
  • 42
  • 4
    Installing ```libblas-dev liblapack-dev``` resolved ```blas``` but then I got ```error: library dfftpack has Fortran sources but no Fortran compiler found``` so I needed all these to be able to install scipy. Thank you. – naoko Aug 16 '15 at 00:37
  • 6
    I just install `libblas-dev liblapack-dev gfortran`, it works for me on Ubuntu14.04 – Jin Jan 06 '16 at 12:57
  • libblas was reason with error - no lapack/blas resources found – Oleg Abrazhaev Jan 30 '16 at 08:09
  • 1
    Amen for unaccepted answers that work better than accepted ones. – Felipe Apr 02 '16 at 01:25
  • for yum: yum install blas-devel lapack-devel atlas-devel gcc-gfortran – Alec McGail May 27 '16 at 19:37
  • Assuming the pip version has similar dependencies as the version provided by the ubuntu repositories, you could simply get all build dependencies using `sudo apt-get build-dep python-numpy python-scipy` – Lanting Jun 01 '16 at 09:35
77

you need the libblas and liblapack dev packages if you are using Ubuntu.

aptitude install libblas-dev liblapack-dev
pip install scipy
Chris Montanaro
  • 16,948
  • 4
  • 20
  • 29
34

I am assuming Linux experience in my answer; I found that there are three prerequisites to getting pip install scipy to proceed nicely.

Go here: Installing SciPY

Follow the instructions to download, build and export the env variable for BLAS and then LAPACK. Be careful to not just blindly cut'n'paste the shell commands - there will be a few lines you need to select depending on your architecture, etc., and you'll need to fix/add the correct directories that it incorrectly assumes as well.

The third thing you may need is to yum install numpy-f2py or the equivalent.

Oh, yes and lastly, you may need to yum install gcc-gfortran as the libraries above are Fortran source.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
David Kierans
  • 1,599
  • 1
  • 16
  • 24
  • instructions you linked in _Installing SciPy_ have been removed, might be linking here now http://www.scipy.org/scipylib/building/windows.html – jxramos Aug 11 '15 at 20:52
  • 31
    -1; this answer has been rendered useless by link breakage. The meat of the answer is to "follow the instructions" at the link, but the page has changed and they're no longer there. Also, the asker was using an OS with `apt-get` as its package manager, but this answer uses `yum`. Nothing wrong with providing answers that cover additional platforms, but they should be signposted as such; this will be needlessly confusing to Unix noobs otherwise. – Mark Amery Mar 14 '16 at 11:32
  • 5
    To install BLAS and LAPACK you need to run `yum install lapack-devel.x86_64 blas-devel.x86_64` – Max L Apr 05 '16 at 11:27
14

Since the previous instructions for installing with yum are broken here are the updated instructions for installing on something like fedora. I've tested this on "Amazon Linux AMI 2016.03"

sudo yum install atlas-devel lapack-devel blas-devel libgfortran
pip install scipy
Greg
  • 5,422
  • 1
  • 27
  • 32
7

I was working on a project that depended on numpy and scipy. In a clean installation of Fedora 23, using a python virtual environment for Python 3.4 (also worked for Python 2.7), and with the following in my setup.py (in the setup() method)

setup_requires=[
    'numpy',
],
install_requires=[
    'numpy',
    'scipy',
],

I found I had to run the following to get pip install -e . to work:

pip install --upgrade pip

and

sudo dnf install atlas-devel gcc-{c++,gfortran} subversion redhat-rpm-config

The redhat-rpm-config is for scipy's use of redhat-hardened-cc1 as opposed to the regular cc1

John
  • 1,709
  • 1
  • 24
  • 27
4

On windows python 3.5, I managed to install scipy by using conda not pip:

conda install scipy
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
3

What operating system is this? The answer might depend on the OS involved. However, it looks like you need to find this BLAS library and install it. It doesn't seem to be in PIP (you'll have to do it by hand thus), but if you install it, it ought let you progress your SciPy install.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shayne
  • 1,571
  • 1
  • 16
  • 20
  • It's ubuntu 11.10. I tried, that is exactly my problem. What is the library and how do I get it? – eran Jun 20 '12 at 11:06
  • 25
    On Ubuntu, you can do e.g. `sudo apt-get install liblapack-dev libatlas-dev` plus maybe also `python-dev gfortran` if you are missing them. – pv. Jun 20 '12 at 11:30
  • 2
    I did not make that post! What the heck? – Shayne Jul 19 '13 at 05:30
0

in my case, upgrading pip did the trick. Also, I've installed scipy with -U parameter (upgrade all packages to the last available version)

fanny
  • 1,373
  • 12
  • 25