Python 在 64 位 Windows 上安装 NumPy 和 SciPy(使用 Pip)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26657334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:49:45  来源:igfitidea点击:

Installing NumPy and SciPy on 64-bit Windows (with Pip)

pythonnumpyscipywindows64

提问by Renzeee

I found out that it's impossible to install NumPy/SciPy via installers on Windows 64-bit, that's only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything.

我发现在 64 位 Windows 上无法通过安装程序安装 NumPy/SciPy,这只能在 32 位上安装。因为我需要比 32 位安装更多的内存,所以我需要 64 位版本的所有东西。

I tried to install everything via Pipand most things worked. But when I came to SciPy, it complained about missing a Fortran compiler. So I installed Fortran via MinGW/MSYS. But you can't install SciPy right away after that, you need to reinstall NumPy. So I tried that, but now it doesn't work anymore via Pipnor via easy_install. Both give these errors:

我试图通过安装所有东西Pip并且大多数东西都有效。但是当我来到 SciPy 时,它抱怨缺少 Fortran 编译器。所以我通过 MinGW/MSYS 安装了 Fortran。但是之后不能马上安装SciPy,需要重新安装NumPy。所以我试过了,但现在它不再工作了 viaPip或 via easy_install。两者都给出了这些错误:

  • There are a lot of errors about LNK2019and LNK1120,.
  • I get a lot of errors in the range of C: C2065,C2054,C2085,C2143`, etc. They belong together I believe.
  • There is no Fortran linker found, but I have no idea how to install that, can't find anything on it.
  • And many more errors which are already out of the visible part of my cmd-windows...
  • The fatal error is about LNK1120:

    build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd : fatal error LNK1120: 7 unresolved externals error: Setup script exited with error: Command "C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\BLAS /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /LIBPATH:build\temp.win-amd64-2.7 lapack.lib blas.lib /EXPORT:initlapack_lite build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_litemodule.obj /OUT:build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.pyd.manifest" failed with exit status 1120

  • 关于LNK2019LNK1120,有很多错误。
  • 我在以下范围内收到很多错误CC2065,C2054 ,C2085 ,C2143` 等。我相信它们属于一起。
  • 没有找到 Fortran 链接器,但我不知道如何安装它,在上面找不到任何东西。
  • 还有更多错误已经超出了我的 cmd-windows 的可见部分......
  • 致命错误是关于LNK1120

    build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd:致命错误 LNK1120:7 未解决的外部错误:安装脚本退出并出现错误:命令“C:\Users\me\AppData\Local\Programs\Common\ Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\BLAS /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\ PCbuild\amd64 /LIBPATH:build\temp.win-amd64-2.7 lapack.lib blas.lib /EXPORT:initlapack_lite build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_litemodule.obj /OUT:build\lib .win-amd64-2.7\numpy\linalg\lapack_lite.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release \numpy\linalg\lapack_lite.pyd.manifest”失败,退出状态为 1120

What is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.

在 64 位 Windows 机器上安装 64 位版本 NumPy 和 SciPy 的正确方法是什么?我错过了什么吗?我需要在某处指定一些东西吗?我找不到有关这些问题的 Windows 信息,仅适用于 Linux 或 Mac OS X,但它们对我没有帮助,因为我无法使用它们的命令。

采纳答案by sebix

EDIT: The Numpy project now provides pre-compiled packages in the wheel format (package format enabling compiled code as binary in packages), so the installation is now as easy as with other packages.

编辑:Numpy 项目现在提供了wheel 格式的预编译包(包格式使编译代码在包中成为二进制),所以现在安装和其他包一样容易。



Numpy (as also some other packages like Scipy, Pandas etc.) includes lot's of C-, Cython, and Fortran code that needs to be compiled properly, before you can use it. This is, btw, also the reason why these Python-packages provide such fast Linear Algebra.

Numpy(以及其他一些软件包,如 Scipy、Pandas 等)包括大量需要正确编译的 C-、Cython 和 Fortran 代码,然后才能使用它。顺便说一句,这也是这些 Python 包提供如此快速的线性代数的原因。

To get precompiled packages for Windows, have a look at Gohlke's Unofficial Windows Binariesor use a distribution like Winpython(just works) or Anaconda(more complex) which provide an entire preconfigured environment with lots of packages from the scientific python stack.

要获得适用于 Windows 的预编译包,请查看Gohlke 的非官方 Windows 二进制文件或使用Winpython(正常工作)或Anaconda(更复杂)之类的发行版,它们提供了一个完整的预配置环境,其中包含来自科学 Python 堆栈的大量包。

回答by Fnord

Look into python wheels to solve your problem. The best part of python wheels is that they let you install C extensions with no compilers. I just installed numpy and scipy using pip in a clean python install and they both worked fine.

查看 python 轮子来解决你的问题。python Wheels 最好的部分是它们让您无需编译器即可安装 C 扩展。我刚刚在干净的 python 安装中使用 pip 安装了 numpy 和 scipy,它们都运行良好。

回答by π?δα? ?κ??

Installing with pip

使用 pip 安装

You can install the numpy and scipy wheels on Windows with pipin one step if you use the appropriate link from Gohlke's Unofficial Windows Binaries(mentioned by sebix) and run the Windows command prompt as Administrator. For example, in Python 3.5, you would simply use something like this:

pip如果您使用Gohlke 的非官方 Windows 二进制文件(由 sebix 提及)中的适当链接并以管理员身份运行 Windows 命令提示符,则可以一步在 Windows 上安装 numpy 和 scipy 轮子。例如,在 Python 3.5 中,您只需使用以下内容:

# numpy-1.9.3+mkl for Python 3.5 on Win AMD64
pip3.5 install http://www.lfd.uci.edu/~gohlke/pythonlibs/xmshzit7/numpy-1.9.3+mkl-cp35-none-win_amd64.whl

# scipy-0.16.1 for Python 3.5 on Win AMD64
pip3.5 install http://www.lfd.uci.edu/~gohlke/pythonlibs/xmshzit7/scipy-0.16.1-cp35-none-win_amd64.whl

回答by be_good_do_good

Best solution for this is to download and install VCforPython2.7 from https://www.microsoft.com/en-us/download/details.aspx?id=44266

最佳解决方案是从https://www.microsoft.com/en-us/download/details.aspx?id=44266下载并安装 VCforPython2.7

Then try pip install numpy

然后尝试 pip install numpy

回答by Koundinya

You can download the needed packages from hereand use pip install "Abc.whl"from the directory where you have downloaded the file.

您可以从这里下载所需的包pip install "Abc.whl"从下载文件的目录中使用。

回答by Lahiruni Abeywickrama

You can install scipy and numpy using their wheels.

您可以使用它们的轮子安装 scipy 和 numpy。

First install wheel package if it's already not there...

如果它已经不存在,请首先安装轮包...

pip install wheel

Just select the package you want from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

只需从http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy 中选择你想要的包

Example: if you're running python3.532 bit on Windows choose scipy-0.18.1-cp35-cp35m-win_amd64.whlthen it will automatically download.

示例:如果您python3.5在 Windows 上运行32 位,则选择scipy-0.18.1-cp35-cp35m-win_amd64.whl它会自动下载。

Then go to the command line and change the directory to the downloads folder and install the above wheel using pip.

然后转到命令行并将目录更改为下载文件夹并使用pip.

Example:

例子:

cd C:\Users\[user]\Downloads
pip install scipy-0.18.1-cp35-cp35m-win_amd64.whl

回答by raffaem

Intel provides pre-compiled Python modules for free in their "Intel Distribution for Python". The modules are compiled against Intel's MKL (Math Kernel Library) and thus optimized for faster performance. The package includes NumPy, SciPy, scikit-learn, pandas, matplotlib, Numba, tbb, pyDAAL, Jupyter, and others. Find more information and the download link here

英特尔在其“英特尔 Python 发行版”中免费提供预编译的 Python 模块。这些模块是针对 Intel 的 MKL(数学内核库)编译的,因此针对更快的性能进行了优化。该软件包包括 NumPy、SciPy、scikit-learn、pandas、matplotlib、Numba、tbb、pyDAAL、Jupyter 等。在此处查找更多信息和下载链接

回答by Gajendra D Ambi

for python 3.6, the following worked for me launch cmd.exe as administrator

对于python 3.6,以下对我有用以管理员身份启动cmd.exe

pip install numpy-1.13.0+mkl-cp36-cp36m-win32 pip install scipy-0.19.1-cp36-cp36m-win32

pip install numpy-1.13.0+mkl-cp36-cp36m-win32 pip install scipy-0.19.1-cp36-cp36m-win32

回答by Meet Zaveri

If you are on windows , you wouldn't need wheel anyway! You can directly install package by downloading the 32-bit package as win32 from this link [http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy]and then move that downloaded package to cmd's current directory and open cmd and write following codepip install numpy-1.13.1+mkl-cp36-cp36m-win32.whlthen do it same for scipy

如果您在 windows 上,无论如何您都不需要轮子!您可以通过从此链接 [ http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy]下载 32 位软件包作为 win32 来直接安装软件包,然后将该下载的软件包移动到 cmd 的当前目录并打开cmd 并编写以下代码pip install numpy-1.13.1+mkl-cp36-cp36m-win32.whl然后对 scipy 执行相同的操作

For 64-bit you need to install mingw-w64 as it is gcc and compiles numpy and scipy as precompiled status.

对于 64 位,您需要安装 mingw-w64,因为它是 gcc 并将 numpy 和 scipy 编译为预编译状态。

Currently it works fine with 32-bit.So I had opted for win32 package both for numpy+mkl and scipy in that link.

目前它在 32 位上运行良好。所以我在那个链接中为 numpy+mkl 和 scipy 选择了 win32 包。

Hope This works! Give a try

希望这有效!试一下

回答by Alexander Vladimirsky

Package version are very important.

包版本非常重要。

I found some stable combination that works on my Windows10 64 bit machine:

我发现了一些适用于我的 Windows10 64 位机器的稳定组合:

pip install numpy-1.12.0+mkl-cp36-cp36m-win64.whl
pip install scipy-0.18.1-cp36-cp36m-win64.whl
pip install matplotlib-2.0.0-cp36-cp36m-win64.whl

Source.

来源