Python - 导入Scipy时出错

时间:2014-08-13 06:01:38

标签: python scipy

我已经看到了处理这个问题的一些解决方案,但我还没有成功解决它。你们其中一个人能告诉我一步一步做什么吗?

退出SciPy源可以做些什么?

顺便说一句,我无法通过pip或easy_install安装SciPy。我已下载并在库中添加了它的文件夹。

ImportError: Error importing scipy: you cannot import scipy while
    being in scipy source directory; please exit the scipy source
    tree first, and relaunch your python intepreter.

[编辑] 解决方案如here。  我正在使用python 2.7。在Windows 7上。

我也看到了在通过pip或easy_install安装scipy之前安装MinGw的方法。我试过但没有改变。

[编辑2] [对不起解释]

当我使用easy_install

时会发生这种情况
C:\Python27\Scripts>easy_install scipy
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Best match: scipy 0.14.0
Downloading https://pypi.python.org/packages/source/s/scipy/scipy-0.14.0.zip#md5
=7ee4fa9e756bab6b46b79f77c821cb68
Processing scipy-0.14.0.zip
Writing c:\users\sali\appdata\local\temp\easy_install-dqnk8b\scipy-0.14.0\setup.
cfg
Running scipy-0.14.0\setup.py -q bdist_egg --dist-dir c:\users\sali\appdata\loca
l\temp\easy_install-dqnk8b\scipy-0.14.0\egg-dist-tmp-nuhhkg
C:\Python27\lib\site-packages\numpy\distutils\system_info.py:576: UserWarning: S
pecified path C:/Program Files (x86)/Intel/Composer XE/mkl/lib/intel64 is invali
d.
  warnings.warn('Specified path %s is invalid.' % d)
C:\Python27\lib\site-packages\numpy\distutils\system_info.py:576: UserWarning: S
pecified path C:/Program Files (x86)/Intel/Composer XE/compiler/lib/intel64 is i
nvalid.
  warnings.warn('Specified path %s is invalid.' % d)
C:\Python27\lib\site-packages\numpy\distutils\system_info.py:576: UserWarning: S
pecified path C:/Program Files (x86)/Intel/Composer XE/mkl/include is invalid.
  warnings.warn('Specified path %s is invalid.' % d)
C:\Python27\lib\site-packages\numpy\distutils\system_info.py:1521: 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__)
C:\Python27\lib\site-packages\numpy\distutils\system_info.py:1530: UserWarning:

    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.
  warnings.warn(BlasNotFoundError.__doc__)
C:\Python27\lib\site-packages\numpy\distutils\system_info.py:1533: UserWarning:

    Blas (http://www.netlib.org/blas/) sources not found.
    Directories to search for the sources can be specified in the
    numpy/distutils/site.cfg file (section [blas_src]) or by setting
    the BLAS_SRC environment variable.
  warnings.warn(BlasSrcNotFoundError.__doc__)
error:
    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.

3 个答案:

答案 0 :(得分:2)

听起来你将scipy的源文件夹复制到某个地方的Python路径中。这是行不通的,因为scipy需要编译;您必须通过源代码目录中的python setup.py install pip / easy_installa binary installer安装它。

答案 1 :(得分:1)

如果您使用的是Windows,请使用提供的二进制文件here安装库。当我尝试使用pip时,来自此站点的软件包的成功率为100%(通常问题是使用C扩展的软件包的C编译步骤)。

答案 2 :(得分:1)

有一堆警告,但只有一个错误:

error:
    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.

最有可能的问题是,您还没有安装BLAS。 (如果有,则错误消息会告诉您如何解决问题。)

某些Python包需要非Python(C)库来构建它们。 Python包lxml需要libxml2scipy需要各种各样的东西,包括BLAS。我们无法pipeasy_install为您解决这些问题。

那么,你怎么知道该怎么办?阅读包的install documentation。如果您不知道它在哪里,只需谷歌" scipy install",或者转到SciPy首页,您就会找到它。

在少数情况下 - 而SciPy就是其中之一 - 先决条件是如此繁重,以至于软件包维护者会建议你甚至不要尝试,除非你真的知道自己在做什么。当你阅读我上面链接的安装文档时,他们的第一个建议是你抛弃你当前的Python并获得一个额外的电池包含的Python版本,如Anaconda或Enthought,随附完整的SciPy堆栈。接下来他们会告诉您如何为大多数平台(但不是Windows)找到完整堆栈的预构建二进制文件。然后他们会告诉你如何为堆栈的特定部分找到预先构建的二进制文件(对于Windows,Christoph Gohkle's archive)。如果您确实想要从源代码构建(使用pip或其他方式),则必须单击该堆栈的每个单独部分,并为每个部分读取一整页新安装说明。

所以,此时,如果您仍想尝试使用pip进行安装,您应该知道接下来的步骤是什么;如果没有,你应该知道你的替代品是什么。