1

I recently installed Python 2.7.11 and am installing some packages. I installed numpy though pip and was trying to install scipy but on running sudo pip install scipy, it gave me the following error.

Collecting scipy
  Downloading scipy-0.17.0.tar.gz (12.4MB)
100% |████████████████████████████████| 12.4MB 143kB/s 
Installing collected packages: scipy
  Running setup.py install for scipy ... error
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-dO0a3N/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-LbzadC-record/install-record.txt --single-version-externally-managed --compile:
lapack_opt_info:
openblas_lapack_info:
  libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
  NOT AVAILABLE

lapack_mkl_info:
mkl_info:
  libraries mkl,vml,guide not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
  NOT AVAILABLE

  NOT AVAILABLE

atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
  libraries tatlas,tatlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries tatlas,tatlas not found in /usr/lib
  libraries lapack_atlas not found in /usr/lib
  libraries tatlas,tatlas not found in /usr/lib/x86_64-linux-gnu
  libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
  NOT AVAILABLE

atlas_3_10_info:
  libraries satlas,satlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries satlas,satlas not found in /usr/lib
  libraries lapack_atlas not found in /usr/lib
  libraries satlas,satlas not found in /usr/lib/x86_64-linux-gnu
  libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
<class 'numpy.distutils.system_info.atlas_3_10_info'>
  NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
  libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib
  libraries lapack_atlas not found in /usr/lib
  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/x86_64-linux-gnu
  libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
<class 'numpy.distutils.system_info.atlas_threads_info'>
  NOT AVAILABLE

atlas_info:
  libraries f77blas,cblas,atlas not found in /usr/local/lib
  libraries lapack_atlas not found in /usr/local/lib
  libraries f77blas,cblas,atlas not found in /usr/lib
  libraries lapack_atlas not found in /usr/lib
  libraries f77blas,cblas,atlas not found in /usr/lib/x86_64-linux-gnu
  libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
<class 'numpy.distutils.system_info.atlas_info'>
  NOT AVAILABLE

/usr/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:1542: 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__)
lapack_info:
  libraries lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
  NOT AVAILABLE

/usr/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:1553: 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__)
lapack_src_info:
  NOT AVAILABLE

/usr/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:1556: 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__)
  NOT AVAILABLE

Running from scipy source directory.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-dO0a3N/scipy/setup.py", line 265, in <module>
    setup_package()
  File "/tmp/pip-build-dO0a3N/scipy/setup.py", line 262, in setup_package
    setup(**metadata)
  File "/usr/local/lib/python2.7/site-packages/numpy/distutils/core.py", line 135, in setup
    config = configuration()
  File "/tmp/pip-build-dO0a3N/scipy/setup.py", line 182, in configuration
    config.add_subpackage('scipy')
  File "/usr/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 1003, in add_subpackage
    caller_level = 2)
  File "/usr/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 972, in get_subpackage
    caller_level = caller_level + 1)
  File "/usr/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 909, in _get_configuration_from_setup_py
    config = setup_module.configuration(*args)
  File "scipy/setup.py", line 15, in configuration
    config.add_subpackage('linalg')
  File "/usr/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 1003, in add_subpackage
    caller_level = 2)
  File "/usr/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 972, in get_subpackage
    caller_level = caller_level + 1)
  File "/usr/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 909, 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

----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-dO0a3N/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-LbzadC-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-dO0a3N/scipy/

So, I proceeded to install it via sudo apt-get install python-scipy, which ran with no problems. But, when I go into the python interpreter and try to import scipy, it says the module does not exist. Where did I go wrong? I also tried the following code.

for p in sys.path:
    if os.path.exists(os.path.join(p, 'numpy')):
        print p
        break
else:
    print "Numpy does not exist"

which resulted in "/usr/local/lib/python2.7/site-packages". Running the same code for scipy says "Scipy does not exist". I think it is a path problem maybe. Any help would be appreciated.

Rahul
  • 502
  • 7
  • 16
  • did you try with easy_install? Also, it seems you are lacking ATLAS and LAPACK as system packages – giosans Apr 12 '16 at 15:48
  • Since you've tried to install `scipy` via multiple methods, you may have `scipy` in `dist-packages` and `site-packages`. Check both locations and check the permissions on the folders. – Nick Apr 12 '16 at 15:51
  • @nick, I checked both `/usr/lib/python2.7/dist-packages` and `/usr/local/lib/python2.7/site-packages`, but I could not find any scipy folder in any of them. Numpy is present in both. – Rahul Apr 12 '16 at 16:30
  • http://stackoverflow.com/a/21073913/4031374 – knh170 Apr 12 '16 at 16:38
  • @knh170, thanks! I found the missing library in that answer. – Rahul Apr 12 '16 at 17:00

2 Answers2

1

In Ubuntu, Python 2.7 packages installed with apt-get install are put in the folder /usr/lib/python2.7/dist-packages. So, you'll need to update you Python path.

export PYTHONPATH="/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/site-packages"

Also, your pip install scipy failed because you didn't install the libraries/packages scipy is dependent on.

Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
1

What I was missing were a dependency of scipy. The library that was missing was libatlas-base-dev. Once I installed that, scipy installed with no problems.

Thanks everyone for sparing time for this. And special mention to @knh170 for the helpful comment. I found the answer there.

Rahul
  • 502
  • 7
  • 16