在 Windows 10 for python 3.7 上使用 pip 安装 numpy
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51087158/
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
Installing numpy with pip on windows 10 for python 3.7
提问by pchegoor
I installed python 3.7 on my Windows 10 laptop since it has been officially released as of today (06/28/2018). Then i tried to install numpy package using pip
自从今天(2018 年 6 月 28 日)正式发布以来,我在 Windows 10 笔记本电脑上安装了 python 3.7。然后我尝试使用 pip 安装 numpy 包
pip install numpy
The install proceeds but finally fails with the below error :
安装继续进行,但最终失败并出现以下错误:
source = func(extension, build_dir)
File "numpy\core\setup.py", line 675, in get_mathlib_info
raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
----------------------------------------
Command ""c:\program files\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\Users\pcheg\AppData\Local\Temp\pip-install-7wjkw5wn\numpy\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\pcheg\AppData\Local\Temp\pip-record-uhj8233f\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\pcheg\AppData\Local\Temp\pip-install-7wjkw5wn\numpy\
Any ideas as to how to overcome this install Error? Thanks.
关于如何克服此安装错误的任何想法?谢谢。
回答by rayryeng
Installing NumPy on Windows is a common problem if you don't have the right build setup. Instead, I always go to Christoph Gohlke's websiteto download the wheels you can install for your computer. Christoph generously builds the libraries himself with the right build environment and he posts it on his website.
如果您没有正确的构建设置,在 Windows 上安装 NumPy 是一个常见问题。相反,我总是去Christoph Gohlke 的网站下载可以为您的计算机安装的轮子。Christoph 慷慨地使用合适的构建环境亲自构建了库,并将其发布在他的网站上。
Newer Instructions - For older instructions, please scroll down
较新的说明 - 有关较旧的说明,请向下滚动
First, install pipwin
from PyPI which will install a utility that acts like pip
but it will download the actual package you're interested in on his website, then use pip install
to install the package you want.
首先,pipwin
从 PyPI安装,它将安装一个实用程序,pip
它会在他的网站上下载您感兴趣的实际包,然后使用它pip install
来安装您想要的包。
First do:
首先做:
pip install pipwin
pip install pipwin
When that's installed, you can then do:
安装后,您可以执行以下操作:
pipwin install numpy
pipwin install numpy
This will install the latest version of NumPy on your system. This way you don't have to specifically search for the version of NumPy that is for your specific version of Python.
这将在您的系统上安装最新版本的 NumPy。这样您就不必专门搜索适用于您的特定 Python 版本的 NumPy 版本。
Older instructions
较旧的说明
Go to the NumPy section: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpythen download the version for 3.7 that is compatible with your version of Python (2 or 3 and 32-bit or 64-bit). For example, the filename numpy?1.14.5+mkl?cp37?cp37m?win_amd64.whl
is for NumPy 1.14.5, Python 3.7 - 64 bit. You can pick out which version of NumPy and which version of the Python interpreter and bit version you need in the filename.
转到 NumPy 部分:https: //www.lfd.uci.edu/~gohlke/pythonlibs/#numpy然后下载与您的 Python 版本(2 或 3 和 32 位或 64-少量)。例如,文件名numpy?1.14.5+mkl?cp37?cp37m?win_amd64.whl
适用于 NumPy 1.14.5、Python 3.7 - 64 位。您可以在文件名中选择您需要哪个版本的 NumPy 以及哪个版本的 Python 解释器和位版本。
Doing this never requires you to build NumPy yourself or install the required compiler as opposed to installing NumPy through PyPI. You can just download the wheel and install it yourself. Assuming you've already downloaded it, just do:
与通过 PyPI 安装 NumPy 相比,这样做永远不需要您自己构建 NumPy 或安装所需的编译器。您只需下载轮子并自行安装即可。假设您已经下载了它,只需执行以下操作:
pip install numpy?1.14.5+mkl?cp37?cp37m?win_amd64.whl
... assuming the wheel is in the directory you're currently in.
...假设轮子在您当前所在的目录中。
回答by Ashish Gupta
For windows when you install a package you type in Python 3:
对于 Windows,当你安装一个你输入 Python 3 的包时:
py -m pip install [packagename]
OR
py -m pip install numpy
回答by Felix
You're probably missing a C compiler. If numpy doesn't provide a prebuilt wheel yet, you'll need to install a compiler. Thiswebsite shows the one you need to install. For 3.7, I assume it's still 14.0, so you should install Microsoft Build Tools for Visual Studio 2017.
您可能缺少 C 编译器。如果 numpy 还没有提供预构建的轮子,你需要安装一个编译器。该网站显示了您需要安装的网站。对于 3.7,我假设它仍然是 14.0,所以你应该安装Microsoft Build Tools for Visual Studio 2017。
Let me know if that works.
让我知道这是否有效。