184
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. 

Which tar do I need to download off this site?

I've tried the fortrans, but I keep getting this error (after setting the environment variable obviously).

1
  • So the question is which is the right version for your system to download from some site, but neither system details nor the site are given in the question? It's not surprising that no answers were forthcoming. Commented Oct 25, 2011 at 11:22

7 Answers 7

341

If you need to use the latest versions of SciPy rather than the packaged version, without going through the hassle of building BLAS and LAPACK, you can follow the below procedure.

Install linear algebra libraries from repository (for Ubuntu),

sudo apt-get install gfortran libopenblas-dev liblapack-dev 

Then install SciPy, (after downloading the SciPy source): python setup.py install or

pip install scipy 

As the case may be.

Sign up to request clarification or add additional context in comments.

9 Comments

This worked for me, tks! Although I had to change libopenblas-dev to libblas-dev (Ubuntu 10.04).
worked perfectly for me running Mint 13 ( precise fork ).You need to download the source separately, if you use easy_install -U #update
It worked flawlessly. I did not have to do anything different in my case (ubuntu 12.0.4)
sudo apt-get install python-dev fixed it. stackoverflow.com/a/21530768/125507
sudo yum install blas-devel lapack-devel worked for me
|
143

The SciPy webpage used to provide build and installation instructions, but the instructions there now rely on OS binary distributions. To build SciPy (and NumPy) on operating systems without precompiled packages of the required libraries, you must build and then statically link to the Fortran libraries BLAS and LAPACK:

mkdir -p ~/src/ cd ~/src/ wget http://www.netlib.org/blas/blas.tgz tar xzf blas.tgz cd BLAS-* ## NOTE: The selected Fortran compiler must be consistent for BLAS, LAPACK, NumPy, and SciPy. ## For GNU compiler on 32-bit systems: #g77 -O2 -fno-second-underscore -c *.f # with g77 #gfortran -O2 -std=legacy -fno-second-underscore -c *.f # with gfortran ## OR for GNU compiler on 64-bit systems: #g77 -O3 -m64 -fno-second-underscore -fPIC -c *.f # with g77 gfortran -O3 -std=legacy -m64 -fno-second-underscore -fPIC -c *.f # with gfortran ## OR for Intel compiler: #ifort -FI -w90 -w95 -cm -O3 -unroll -c *.f # Continue below irrespective of compiler: ar r libfblas.a *.o ranlib libfblas.a rm -rf *.o export BLAS=~/src/BLAS-*/libfblas.a 

Execute only one of the five g77/gfortran/ifort commands. I have commented out all, but the gfortran which I use. The subsequent LAPACK installation requires a Fortran 90 compiler, and since both installs should use the same Fortran compiler, g77 should not be used for BLAS.

Next, you'll need to install the LAPACK stuff. The SciPy webpage's instructions helped me here as well, but I had to modify them to suit my environment:

mkdir -p ~/src cd ~/src/ wget http://www.netlib.org/lapack/lapack.tgz tar xzf lapack.tgz cd lapack-*/ cp INSTALL/make.inc.gfortran make.inc # On Linux with lapack-3.2.1 or newer make lapacklib make clean export LAPACK=~/src/lapack-*/liblapack.a 

Update on 3-Sep-2015: Verified some comments today (thanks to all): Before running make lapacklib edit the make.inc file and add -fPIC option to OPTS and NOOPT settings. If you are on a 64bit architecture or want to compile for one, also add -m64. It is important that BLAS and LAPACK are compiled with these options set to the same values. If you forget the -fPIC SciPy will actually give you an error about missing symbols and will recommend this switch. The specific section of make.inc looks like this in my setup:

FORTRAN = gfortran OPTS = -O2 -frecursive -fPIC -m64 DRVOPTS = $(OPTS) NOOPT = -O0 -frecursive -fPIC -m64 LOADER = gfortran 

On old machines (e.g. RedHat 5), gfortran might be installed in an older version (e.g. 4.1.2) and does not understand option -frecursive. Simply remove it from the make.inc file in such cases.

The lapack test target of the Makefile fails in my setup because it cannot find the blas libraries. If you are thorough you can temporarily move the blas library to the specified location to test the lapack. I'm a lazy person, so I trust the devs to have it working and verify only in SciPy.

8 Comments

There is no libfblas in blas.tgz though.
Worked for me, but I had to edit the make.inc file by setting OPTS = -O2 -fPIC and NOOPT = -O0 -fPIC.
@jdborg it is apparently called just liblapack.a now
I had to add the -m64 options to the OPTS and NOOPT settings in the make.inc file. Only of you are on a 64 bit machine of course.
+1 Many thanks for this! Also, for scipy, I had to do export LAPACK=~/src/lapack-3.5.0/ instead of adding the libflapack.a in the end.
|
66

On Fedora, this works:

 yum install lapack lapack-devel blas blas-devel pip install numpy pip install scipy 

Remember to install 'lapack-devel' and 'blas-devel' in addition to 'blas' and 'lapack' otherwise you'll get the error you mentioned or the "numpy.distutils.system_info.LapackNotFoundError" error.

5 Comments

It says "public key for blas-dev.." not installed. :(
@OlgaMu Use "yum --nogpgcheck install blas-devel"
blas-static & lapack-static were required for me on fedora 20.
Thank you! This worked for me on my AWS EC2 Amazon Linux machine.
This doesn't work for a virtualenvironment though, it is failing unless I use sudo for the pip install. Any ideas?
44

I guess you are talking about installation in Ubuntu. Just use:

apt-get install python-numpy python-scipy 

That should take care of the BLAS libraries compiling as well. Else, compiling the BLAS libraries is very difficult.

4 Comments

@V3ss0n, building BLAS and LAPACK are notoriously difficult. It is much easier to compile and install kernels from scratch than compiling those two damned packages imho.
@Coder, I figured out how to do this on my Debian box. Should work for Ubuntu as well. check this out: ydevel.tumblr.com/post/37462965735/… [DISCLAIMER: I'm the author of the post]
@NicholasMancuso It is indeed difficult but I manage to build whole python (Relocatable) + Lapack + ATLAS (Better than BLAS) Scipy , Scikit, Maplotlib , NetworkX , and alot of other C Dependencies . My whole Runtime folder now 900 MB (Python , Perl , Java included too) haha,. But that makes my projects totally relocated with its own runtime in one folder. Let me know if you need it. Way a lot better than Virtualenv.
@yatisagade, @Coder, indeed, you need to be able to use pip install scipy or build it from source in a virtual environment.
12

For Windows users there is a nice binary package by Chris (warning: it's a pretty large download, 191 MB):

Comments

2

Following the instructions given by 'cfi' works for me, although there are a few pieces they left out that you might need:

1) Your lapack directory, after unzipping, may be called lapack-X-Y (some version number), so you can just rename that to LAPACK.

cd ~/src mv lapack-[tab] LAPACK 

2) In that directory, you may need to do:

cd ~/src/LAPACK cp lapack_LINUX.a libflapack.a 

Comments

-2

Try using

sudo apt-get install python3-scipy 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.