我最近安装了Python 2.7.11并安装了一些软件包。我虽然numpy
安装了pip
并试图安装scipy
,但在运行sudo pip install scipy
时,它给了我以下错误。
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/
所以,我继续通过sudo apt-get install python-scipy
安装它,它运行没有问题。但是,当我进入python解释器并尝试导入scipy时,它表示该模块不存在。我哪里做错了?我也尝试了以下代码。
for p in sys.path:
if os.path.exists(os.path.join(p, 'numpy')):
print p
break
else:
print "Numpy does not exist"
导致&#34; /usr/local/lib/python2.7/site-packages
&#34;。为scipy运行相同的代码说&#34; Scipy不存在&#34;。我认为这可能是一个路径问题。任何帮助将不胜感激。
答案 0 :(得分:1)
在Ubuntu中,与apt-get install
一起安装的Python 2.7软件包放在文件夹/usr/lib/python2.7/dist-packages
中。因此,您需要更新Python路径。
export PYTHONPATH="/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/site-packages"
此外,您的pip install scipy
失败了,因为您没有安装scipy所依赖的库/包。
答案 1 :(得分:1)
我缺少的是scipy
的依赖。缺少的库是libatlas-base-dev
。安装完毕后,安装scipy
没有任何问题。
感谢大家节省时间。特别提到@ knh170的有用评论。我找到了答案。