2016-04-12 121 views
0

我最近安裝了Python 2.7.11,並且正在安裝一些軟件包。我安裝了numpy雖然pip並試圖安裝scipy但運行sudo pip install scipy,它給了我以下錯誤。雖然已經安裝,但不能導入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" 

導致「/usr/local/lib/python2.7/site-packages」。爲scipy運行相同的代碼說「Scipy不存在」。我認爲這可能是一個路徑問題。任何幫助,將不勝感激。

+0

你用easy_install試過嗎?另外,它似乎缺少ATLAS和LAPACK作爲系統軟件包 – giosans

+0

由於您試圖通過多種方法安裝'scipy',因此'dist-packages'和'site-packages'中可能有'scipy'。檢查兩個位置並檢查文件夾的權限。 – Nick

+0

@nick,我檢查了'/ usr/lib/python2.7/dist-packages'和'/ usr/local/lib/python2.7/site-packages',但是我找不到任何scipy文件夾他們。兩種都有Numpy。 – Rahul

回答

1

我失蹤的是scipy的依賴關係。缺失的圖書館是libatlas-base-dev。一旦我安裝,scipy安裝沒有問題。

感謝大家爲此節省時間。特別提及@ knh170的有用評論。我在那裏找到了答案。

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的依賴。

+0

我試過命令,但無濟於事。 'ImportError:No module named scipy' – Rahul

+0

你能告訴我如何安裝依賴項,所以我可以使用'pip'來安裝'scipy'嗎? – Rahul

+0

我不知道確切的依賴關係是什麼,但[此答案](http://stackoverflow.com/a/36000635/250168)列出了scipy,numpy,pandas和其他一些軟件包的依賴關係。 –

相關問題