【问题标题】:Unable to install Scipy using pip无法使用 pip 安装 Scipy
【发布时间】:2016-08-03 16:04:43
【问题描述】:

我在 cmd 中使用了“pip install scipy”命令,但最后得到了这个错误。我该如何解决?

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Spencer>pip install scipy
Collecting scipy
  Using cached scipy-0.17.0.tar.gz
Complete output from command python setup.py egg_info:
non-existing path in 'numpy\\distutils': 'site.cfg'
Running from numpy source directory.
c:\users\spencer\appdata\local\temp\easy_install-3pkkpt\numpy-1.11.0\setup.py:327: UserWarning:
Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
  warnings.warn("Unrecognized setuptools command, proceeding with "
c:\users\spencer\appdata\local\temp\easy_install-3pkkpt\numpy-1.11.0\numpy\distutils\system_info
.py:1640: 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:\users\spencer\appdata\local\temp\easy_install-3pkkpt\numpy-1.11.0\numpy\distutils\system_info
.py:1649: 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:\users\spencer\appdata\local\temp\easy_install-3pkkpt\numpy-1.11.0\numpy\distutils\system_info
.py:1652: 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__)
c:\users\spencer\appdata\local\temp\easy_install-3pkkpt\numpy-1.11.0\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__)
c:\users\spencer\appdata\local\temp\easy_install-3pkkpt\numpy-1.11.0\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__)
c:\users\spencer\appdata\local\temp\easy_install-3pkkpt\numpy-1.11.0\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__)
c:\python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'define_macros'

  warnings.warn(msg)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\spencer\appdata\local\temp\pip-build-i4x0vy\scipy\setup.py", line 265, in <modu
le>
    setup_package()
  File "c:\users\spencer\appdata\local\temp\pip-build-i4x0vy\scipy\setup.py", line 262, in setup
_package
    setup(**metadata)
  File "c:\python27\lib\distutils\core.py", line 111, in setup
    _setup_distribution = dist = klass(attrs)
  File "c:\python27\lib\site-packages\setuptools\dist.py", line 268, in __init__
    self.fetch_build_eggs(attrs['setup_requires'])
  File "c:\python27\lib\site-packages\setuptools\dist.py", line 313, in fetch_build_eggs
    replace_conflicting=True,
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 836, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1081, in best_match
    return self.obtain(req, installer)
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1093, in obtain
    return installer(requirement)
  File "c:\python27\lib\site-packages\setuptools\dist.py", line 380, in fetch_build_egg
    return cmd.easy_install(req)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 629, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 659, in install_
item
    dists = self.install_eggs(spec, download, tmpdir)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 842, in install_
eggs
    return self.build_and_install(setup_script, setup_base)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1070, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1058, in run_set
up
    raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in       c:\users\spencer\appdata\local\temp\pip-build-i4x0vy\scipy\

编辑:添加了整个错误 帖子代码太多,不让我发,请忽略接下来的这些句子,因为它只是为了在我发布之前填写所需的数量。

【问题讨论】:

  • 更新了评论,使其包含整个错误
  • 您的问题是缺乏基础科学库,根据this 页面,在 Windows 上构建它们很痛苦。 Scipy 需要一个 whole stack 的包才能正常工作,推荐的解决方案是使用预编译的包,如@MattDMo 的回答。

标签: python windows pip


【解决方案1】:

从这个网站下载你的python版本的安装程序:https://github.com/scipy/scipy/releases

有很多文件可以从网站下载,但例如对于 python 2.7,正确的安装程序名为 scipy-0.16.1-win32-superpack-python2.7.exe 下载文件后,点击几下即可轻松安装 Scipy。

【讨论】:

  • 除了 scipy 的最新版本是 0.17.0,并且该页面上没有它的可执行安装程序。
【解决方案2】:

对于 Windows 上需要编译的模块,只需使用 Christoph Gohlke 的 Python Extension Packages for Windows 存储库即可。你可以下载scipyhere,但是你还需要安装numpy的MKL版本。

下载.whl 文件后,只需使用以下命令安装它们

pip install -U wheel_file_name.whl

-U 用于升级,以防您已经安装了以前的版本。

【讨论】:

  • 使用 .whl 文件和直接从 pip 安装有什么区别?问是因为我花了将近一个小时试图通过 pip 安装(我的意思是 PyPi 包)但从来没有让它工作。几乎要安装 Anaconda 来处理这个问题,但看到你的评论并安装了 scipy。谢谢。
【解决方案3】:

看来您必须安装 cython。我遇到了同样的错误,“sudo pip install cython”解决了这个问题。看这里build scipy error cythonize failed

【讨论】:

    【解决方案4】:

    在错误中它说:“Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27

    【讨论】: