62

I would like to run a programme that someone else has prepared and it includes scipy. I have tried to install scipy with

pip install scipy

but it gives me a long error. I know there are ways with Anaconda and Canopy but I think these are long ways. I would like to have a short way. I have also tried

G:\determinator_Oskar>pip install scipy
Collecting scipy
  Using cached scipy-0.16.1.tar.gz
Building wheels for collected packages: scipy
  Running setup.py bdist_wheel for scipy
  Complete output from command g:\myve\scripts\python.exe -c "import setuptools;
__file__='e:\\temp_n~1\\pip-build-1xigxu\\scipy\\setup.py';exec(compile(open(__f
ile__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d e:\temp_
n~1\tmp07__zrpip-wheel-:
  lapack_opt_info:
  openblas_lapack_info:
    libraries openblas not found in ['g:\\myve\\lib', 'C:\\']
    NOT AVAILABLE

  lapack_mkl_info:
  mkl_info:
    libraries mkl,vml,guide not found in ['g:\\myve\\lib', 'C:\\']
    NOT AVAILABLE

    NOT AVAILABLE

  atlas_3_10_threads_info:
  Setting PTATLAS=ATLAS
    libraries tatlas,tatlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries tatlas,tatlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
    NOT AVAILABLE

  atlas_3_10_info:
    libraries satlas,satlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries satlas,satlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_3_10_info'>
    NOT AVAILABLE

  atlas_threads_info:
  Setting PTATLAS=ATLAS
    libraries ptf77blas,ptcblas,atlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries ptf77blas,ptcblas,atlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_threads_info'>
    NOT AVAILABLE

  atlas_info:
    libraries f77blas,cblas,atlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries f77blas,cblas,atlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_info'>
    NOT AVAILABLE

  lapack_info:
    libraries lapack not found in ['g:\\myve\\lib', 'C:\\']
    NOT AVAILABLE

  lapack_src_info:
    NOT AVAILABLE

    NOT AVAILABLE

  g:\myve\lib\site-packages\numpy\distutils\system_info.py:1552: UserWarning:
      Atlas (http://math-atlas.sourceforge.net/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [atlas]) or by setting
      the ATLAS environment variable.
    warnings.warn(AtlasNotFoundError.__doc__)
  g:\myve\lib\site-packages\numpy\distutils\system_info.py:1563: UserWarning:
      Lapack (http://www.netlib.org/lapack/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [lapack]) or by setting
      the LAPACK environment variable.
    warnings.warn(LapackNotFoundError.__doc__)
  g:\myve\lib\site-packages\numpy\distutils\system_info.py:1566: UserWarning:
      Lapack (http://www.netlib.org/lapack/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [lapack_src]) or by setting
      the LAPACK_SRC environment variable.
    warnings.warn(LapackSrcNotFoundError.__doc__)
  Running from scipy source directory.
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 253, in <module>
      setup_package()
    File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 250, in setup_packa
ge
      setup(**metadata)
    File "g:\myve\lib\site-packages\numpy\distutils\core.py", line 135, in setup

      config = configuration()
    File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 175, in configurati
on
      config.add_subpackage('scipy')
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001, in
 add_subpackage
      caller_level = 2)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, in
get_subpackage
      caller_level = caller_level + 1)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, in
_get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "scipy\setup.py", line 15, in configuration
      config.add_subpackage('linalg')
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001, in
 add_subpackage
      caller_level = 2)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, in
get_subpackage
      caller_level = caller_level + 1)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, in
_get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "scipy\linalg\setup.py", line 20, in configuration
      raise NotFoundError('no lapack/blas resources found')
  numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

  ----------------------------------------
  Failed building wheel for scipy
Failed to build scipy
Installing collected packages: scipy
  Running setup.py install for scipy
    Complete output from command g:\myve\scripts\python.exe -c "import setuptool
s, tokenize;__file__='e:\\temp_n~1\\pip-build-1xigxu\\scipy\\setup.py';exec(comp
ile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __fi
le__, 'exec'))" install --record e:\temp_n~1\pip-3hncqr-record\install-record.tx
t --single-version-externally-managed --compile --install-headers g:\myve\includ
e\site\python2.7\scipy:
    lapack_opt_info:
    openblas_lapack_info:
      libraries openblas not found in ['g:\\myve\\lib', 'C:\\']
      NOT AVAILABLE

    lapack_mkl_info:
    mkl_info:
      libraries mkl,vml,guide not found in ['g:\\myve\\lib', 'C:\\']
      NOT AVAILABLE

      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas,tatlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries tatlas,tatlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries satlas,satlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries satlas,satlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries ptf77blas,ptcblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries f77blas,cblas,atlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries f77blas,cblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in ['g:\\myve\\lib', 'C:\\']
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    g:\myve\lib\site-packages\numpy\distutils\system_info.py:1552: UserWarning:
        Atlas (http://math-atlas.sourceforge.net/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [atlas]) or by setting
        the ATLAS environment variable.
      warnings.warn(AtlasNotFoundError.__doc__)
    g:\myve\lib\site-packages\numpy\distutils\system_info.py:1563: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      warnings.warn(LapackNotFoundError.__doc__)
    g:\myve\lib\site-packages\numpy\distutils\system_info.py:1566: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      warnings.warn(LapackSrcNotFoundError.__doc__)
    Running from scipy source directory.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 253, in <module>
        setup_package()
      File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 250, in setup_pac
kage
        setup(**metadata)
      File "g:\myve\lib\site-packages\numpy\distutils\core.py", line 135, in set
up
        config = configuration()
      File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 175, in configura
tion
        config.add_subpackage('scipy')
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001,
in add_subpackage
        caller_level = 2)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, i
n get_subpackage
        caller_level = caller_level + 1)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, i
n _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy\setup.py", line 15, in configuration
        config.add_subpackage('linalg')
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001,
in add_subpackage
        caller_level = 2)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, i
n get_subpackage
        caller_level = caller_level + 1)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, i
n _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy\linalg\setup.py", line 20, in configuration
        raise NotFoundError('no lapack/blas resources found')
    numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

    ----------------------------------------
Command "g:\myve\scripts\python.exe -c "import setuptools, tokenize;__file__='e:
\\temp_n~1\\pip-build-1xigxu\\scipy\\setup.py';exec(compile(getattr(tokenize, 'o
pen', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install
--record e:\temp_n~1\pip-3hncqr-record\install-record.txt --single-version-exter
nally-managed --compile --install-headers g:\myve\include\site\python2.7\scipy"
failed with error code 1 in e:\temp_n~1\pip-build-1xigxu\scipy      

I have also tried

pip install lapack

with this result

Collecting lapack
  Could not find a version that satisfies the requirement lapack (from versions
 )
No matching distribution found for lapack

I have also tried

pip install blas

with similar results

G:\determinator_Oskar>pip install blas
Collecting blas
  Could not find a version that satisfies the requirement blas (from versions: )

No matching distribution found for blas

Why does a scipy get so complicated ?

Marko
  • 719
  • 1
  • 6
  • 16
  • 1
    I did `yum install lapack` which installed lapack and blas, but it didn't solve the problem either... – Paul Feb 16 '16 at 10:56
  • 11
    `sudo yum install blas-devel lapack-devel` needed on RedHat or CentOS. `sudo apt-get install gfortran libopenblas-dev liblapack-dev python-dev` on Debian or Ubuntu. YMMV. – gaoithe May 30 '16 at 15:26
  • @gaoithe If I use that redhat command on a fresh EC2 Redhat image, I get an error message because that packages are not available. (i.e. wrong package name) – falsePockets Sep 08 '17 at 03:52
  • @falsePockets try libblas-devel and liblapack-devel and see https://stackoverflow.com/questions/15777836/how-to-install-scipy-on-ec2-server – gaoithe Sep 08 '17 at 13:20
  • I was facing the same problem, upgrading pip helped me – Shah Muzaffar Feb 22 '18 at 10:30
  • 'I know there are ways with Anaconda and Canopy but I think these are long ways.' Did you know conda was literally invented for this exact problem? Thinking is great; but have you tried, you know, trying? – Eelco Hoogendoorn Jun 08 '19 at 18:38
  • I was facing the same issue and I fixed it by doing `export OPENBLAS="$(brew --prefix openblas)"` – Pablo Fernandez Aug 28 '22 at 21:56

11 Answers11

60

For Debian Jessie and Stretch installing the following packages resolves the issue:

sudo apt install libblas3 liblapack3 liblapack-dev libblas-dev

Your next issue is very likely going to be a missing Fortran compiler, resolve this by installing it like this:

sudo apt install gfortran

If you want an optimized scipy, you can also install the optional libatlas-base-dev package:

sudo apt install libatlas-base-dev

Source


If you have any issue with a missing Python.h file like this:

Python.h: No such file or directory

Then have a look at this post: https://stackoverflow.com/a/21530768/209532

chjortlund
  • 3,613
  • 2
  • 31
  • 30
35

The SciPy installation page already recommends several ways of installing python with SciPy already included, such as WinPython.

Another way is to use wheels (a built-package format):

pip install SomePackage-1.0-py2.py3-none-any.whl

The wheel packages you can find on: http://www.lfd.uci.edu/~gohlke/pythonlibs/

For SciPy you need:

agold
  • 6,140
  • 9
  • 38
  • 54
  • 7
    Hey guys, thank you and thank God for miniconda. It worked like a miracle. Install and run `conda install scipy`, like you suggested @jakedvp. Now my programme is running and I am happy. Have a nice day :) – Marko Oct 27 '15 at 15:04
  • I have windows 10 and it doesn't allow me to install using wheels. What can I do – jayz Jun 04 '17 at 01:48
  • Have you tried any of the other solutions? If that still doesn't work, you can ask a new question, explaining what you have tried and what errors you got. – agold Jun 04 '17 at 10:01
  • This worked for me. I downloaded the *.whl file and copied to the directory where pip is installed and then ran the command as "pip install filename.whl" – Amir Md Amiruzzaman Jul 01 '17 at 00:59
  • it's `numpy` that warns about BLAS and LAPACK. Using `numpy` wheel does not solve the problem, since it does not contains the optimized libraries. Furthermore, `scipy` already requires `numpy`, so... – Marco Sulla Dec 29 '19 at 00:07
  • 1
    On the page, there is no information whatsoever about blas/lapack instalation, and the wheel do not cover all versions you could need. – Adam Bajger Feb 28 '20 at 11:18
30

"Why does a scipy get so complicated?

It gets so complicated because Python's package management system is built to track Python package dependencies, and SciPy and other scientific tools have dependencies beyond Python. Wheels fix part of the problem, but my experience is that tools like pip/virtualenv are just not sufficient for installing and managing a scientific Python stack.

If you want an easy way to get up and running with SciPy, I would highly suggest the Anaconda distribution. It will give you everything you need for scientific computing in Python.

If you want a "short way" of doing this (I'm interpreting that as "I don't want to install a huge distribution"), you might try miniconda and then run conda install scipy.

jakevdp
  • 77,104
  • 11
  • 125
  • 160
6

Always for Ubuntu/Debian, chjortlund's answer it's very good but not perfect, since this way you get an unoptimized BLAS library. You have simply to do:

sudo apt install libatlas-base-dev

and voila'!

Source

Marco Sulla
  • 15,299
  • 14
  • 65
  • 100
4

Using conda install scipy instead of pip solved the problem for me!

Bilal
  • 517
  • 5
  • 7
2

For windows: Best is to use pre-compiled package available from this site: http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#scipy

Hmnshu
  • 230
  • 1
  • 5
  • 13
0

For completeness, though this probably would not work well given your particular setup (external program + Windows), one can also acquire Scipy hassle-free as part of the (large) SageMath download.

kcrisman
  • 4,374
  • 20
  • 41
0

Either use SciPy whl, download the appropriate one and run pip install <whl_file>

OR

Read through SciPy Windows issue and run one of the methods.

OR

Use Miniconda.

Additionally, install Visual C++ compiler for python2.7 in-case it asks for it.

Ani Menon
  • 27,209
  • 16
  • 105
  • 126
0

I got this problem on freeBSD. It seems lapack packages are missing, I solved it installing them (as root) with:

pkg install lapack
pkg install atlas-devel  #not sure this is needed, but just in case

I imagine it could work on other system too using the appropriate package installer (e.g. apt-get)

Vincenzooo
  • 2,013
  • 1
  • 19
  • 33
0

pip install Cython

before

pip install sklearn

did the trick for me.

Bertrand Gazanion
  • 705
  • 1
  • 14
  • 19
Mike N
  • 1
0
conda install liblapack

this worked for me