Python 如何使用 pip install 在 Windows 上安装 numpy?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29499815/
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 04:40:02  来源:igfitidea点击:

How to install numpy on windows using pip install?

pythonpython-2.7visual-c++numpypip

提问by DartLenin

I want to install numpy using pip install numpycommand but i get follwing error:

我想使用pip install numpy命令安装 numpy,但出现以下错误:

RuntimeError: Broken toolchain: cannot link a simple C program

I'm using windows 7 32bit, python 2.7.9, pip 6.1.1 and some MSVC compiler. I think it uses compiler from Visual C++ 2010 Express, but actually I'm not sure which one because I have several visual studio installations.

我正在使用 windows 7 32 位、python 2.7.9、pip 6.1.1 和一些 MSVC 编译器。我认为它使用 Visual C++ 2010 Express 的编译器,但实际上我不确定是哪一个,因为我有几个 Visual Studio 安装。

I know that there are prebuilt packages for windows but I want to figure out if there is some way to do it just by typing pip install numpy?

我知道有适用于 Windows 的预构建包,但我想知道是否有某种方法可以通过键入pip install numpy?

Edit: I think that there could be other packages which must be compiled before usage, so it's not only about numpy. I want to solve the problem with my compiler so I could easily install any other similar package without necessity to search for prebuilt packages (and hope that there are some at all)

编辑:我认为可能还有其他包必须在使用前编译,所以它不仅仅是关于 numpy. 我想用我的编译器解决这个问题,这样我就可以轻松安装任何其他类似的包,而无需搜索预构建的包(并希望有一些)

采纳答案by Akhilesh Shukla

Installing extension modules can be an issue with pip. This is why conda exists. conda is an open-source BSD-licensed cross-platform package manager. It can easily install NumPy.

安装扩展模块可能是 pip 的问题。这就是 conda 存在的原因。conda 是一个开源的 BSD 许可的跨平台包管理器。它可以轻松安装 NumPy。

Two options:

两种选择:

  • Install Anaconda here
  • Install Miniconda hereand then go to a command-line and type conda install numpy(make sure your PATH includes the location conda was installed to).
  • 在此处安装 Anaconda
  • 在此处安装 Miniconda ,然后转到命令行并键入conda install numpy(确保您的 PATH 包含安装 conda的位置)。

回答by acs

Check installation of python 2.7 than install/reinstall pip which described herethan open command line and write

检查python 2.7的安装而不是安装/重新安装pip,这里描述的不是打开命令行并写入

pip install numpy

or

或者

pip install scipy

if already installed try this

如果已经安装试试这个

pip install -U numpy

回答by Colonel Panic

Frustratingly the Numpy package published to PyPI won't install on most Windows computers https://github.com/numpy/numpy/issues/5479

令人沮丧的是,发布到 PyPI 的 Numpy 包不会安装在大多数 Windows 计算机上https://github.com/numpy/numpy/issues/5479

Instead:

反而:

  1. Download the Numpy wheel for your Python version from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
  2. Install it from the command line pip install numpy-1.10.2+mkl-cp35-none-win_amd64.whl
  1. http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy下载适用于您的 Python 版本的 Numpy 轮
  2. 从命令行安装它 pip install numpy-1.10.2+mkl-cp35-none-win_amd64.whl

回答by leewz

As of March 2016, pip install numpyworks on Windows without a Fortran compiler. See here.

截至 2016 年 3 月,pip install numpy可在没有 Fortran 编译器的 Windows 上运行。见这里

pip install scipystill tries to use a compiler.

pip install scipy仍然尝试使用编译器。

July 2018: mojoken reports pip install scipyworking on Windows without a Fortran compiler.

2018 年 7 月:mojoken 报告pip install scipy在没有 Fortran 编译器的情况下在 Windows 上工作。

回答by juzer tarwala

First go through this link https://www.python.org/downloads/to download python 3.6.1 or 2.7.13 either of your choice.I preferred to use python 2.7 or 3.4.4 .now after installation go to the folder name python27/python34 then click on script now here open the command prompt by left click ad run as administration. After the command prompt appear write their "pip install numpy" this will install the numpy latest version and installing it will show success comment that's all. Similarly matplotlib can be install by just typing "pip install matplotlip". And now if you want to download scipy then just write "pip install scipy" and if it doesn't work then you need to download python scipy from the link https://sourceforge.net/projects/scipy/and install it.

首先通过此链接https://www.python.org/downloads/下载您选择的 python 3.6.1 或 2.7.13。我更喜欢使用 python 2.7 或 3.4.4 .now 安装后转到文件夹命名 python27/python34 然后点击脚本现在在这里通过左键点击打开命令提示符,以管理员身份运行。在命令提示符出现后,写下他们的“pip install numpy”,这将安装 numpy 最新版本,安装它会显示成功注释。同样,只需键入“pip install matplotlip”即可安装 matplotlib。现在,如果您想下载 scipy,那么只需编写“pip install scipy”,如果它不起作用,那么您需要从https://sourceforge.net/projects/scipy/链接下载 python scipy并安装它。

回答by Ivan Zadorozhniy

I had the same problem. I decided in a very unexpected way. Just opened the command line as an administrator. And then typed:

我有同样的问题。我以一种非常出乎意料的方式做出了决定。刚刚以管理员身份打开命令行。然后输入:

pip install numpy

回答by Jonathas Groetares

Install miniconda (here)

安装 miniconda (这里)

After installed, open Anaconda Prompt (search this in Start Menu)

安装后,打开 Anaconda Prompt(在开始菜单中搜索)

Write:

写:

pip install numpy

After installed, test:

安装后,测试:

import numpy as np

回答by Vinorth

py -m pip install numpy

Worked for me!

为我工作!