Python 如何在 Windows 上更新 numpy 1.11

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

How update numpy 1.11 on Windows

pythonwindowsnumpy

提问by Cass

First of all I know this subject is duplicate, but if I understood the problem, I wouldn't come here to ask my question.

首先我知道这个主题是重复的,但是如果我理解了这个问题,我就不会来这里问我的问题了。

I read
Explain why numpy should not be imported from source directoryand probably 2^6 other sites/questions/solution (pip etc..) with similar issues, but I still don't understand. I'm a beginner, I have no problem when I update library of python on ubuntu, but on windows, I've lost my nerves.

我阅读了
解释为什么不应从源目录导入 numpy以及可能存在类似问题的 2^6 个其他站点/问题/解决方案(pip 等),但我仍然不明白。我是初学者,我在 ubuntu 上更新 python 库时没有问题,但是在 Windows 上,我已经失去了神经。

So I will explain the way I update my library :

所以我将解释我更新我的图书馆的方式:

I go on https://github.com/numpy/numpy/releases

我继续https://github.com/numpy/numpy/releases

I take the v.1.11.0 (the zip)

我拿 v.1.11.0 (zip)

I get the file numpy-1.11.0.zip in downloads

我在下载中得到文件 numpy-1.11.0.zip

I delete the file 'numpy' in C:\Python27\Lib\site-packages

我删除了 C:\Python27\Lib\site-packages 中的文件“numpy”

I put my new file numpy-1.11.0.zip in site-packages

我把我的新文件 numpy-1.11.0.zip 放在 site-packages

I unzip that file.

我解压那个文件。

I click on all of the .py of that upzip file

我单击该 upzip 文件的所有 .py

When I try to compile my code (which work on previous version of numpy), I get an error:

当我尝试编译我的代码(适用于以前版本的 numpy)时,出现错误:

ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python intepreter from there.

导入错误:导入 numpy 时出错:您不应该尝试从其源目录导入 numpy;请退出 numpy 源代码树,然后从那里重新启动您的 python 解释器。

Where did I fail to update my numpy library? Could someone explain to me in a simple way, because I'm really a noob.

我在哪里未能更新我的 numpy 库?有人可以用简单的方式向我解释,因为我真的是一个菜鸟。

回答by DavidG

Pip is the easiest way to go installing packages. Your first problem appears to be that windows isn't recognising python as a command. In order to fix this you need to add it to the PATH environment variable.

Pip 是安装软件包的最简单方法。您的第一个问题似乎是 windows 无法将 python 识别为命令。为了解决这个问题,您需要将其添加到 PATH 环境变量中。

  1. Open Start Menu and right click My Computer. Click on Advanced System Settings.
  2. Click on Environment Variables
  3. Find the PATH variable and click Edit. You want to add Python to this PATH variable by adding exactly ;C:\Python27
  1. 打开开始菜单并右键单击我的电脑。单击高级系统设置。
  2. 点击环境变量
  3. 找到 PATH 变量并单击编辑。您想通过精确添加 ;C:\Python27 将 Python 添加到此 PATH 变量

According to the documentationyour version of Python, 2.7.9, should come with pip installed so no need for you to do anything there.

根据文档,您的 Python 版本 2.7.9 应该安装了 pip,因此您无需在那里执行任何操作。

Open the command prompt and type pip install --upgrade numpyand it should upgrade to the newest version.

打开命令提示符并键入pip install --upgrade numpy,它应该升级到最新版本。

回答by Chris Mueller

Both numpy and scipy have problems installing from pypi(the default repository of pip) on windows. The way I always install it it to download the .whlfiles from Christoper Gohlke's siteand install them with pip.

numpy 和 scipy在 Windows 上从pypi(pip 的默认存储库)安装时都有问题。我总是安装它的方式是.whlChristoper Gohlke 的站点下载文件并使用 pip 安装它们。

For example, if you are running Python 3.5 on a 64 bit machine:

例如,如果您在 64 位机器上运行 Python 3.5:

  • Start by downloading numpy-1.11.1+mkl-cp35-cp35m-win_amd64.whlfrom the site linked above
  • After the download is finished, open a powershell window and cdto your python scripts directory (mine is C:\\Python35\Scripts).
  • From there you can use pip to install the whl file with pip install C:\Users\USERNAME\Downloads\numpy-1.11.1+mkl-cp35-cp35m-win_amd64.whl
  • 首先numpy-1.11.1+mkl-cp35-cp35m-win_amd64.whl从上面链接的站点下载
  • 下载完成后,打开一个 powershell 窗口并cd进入您的 python 脚本目录(我的是C:\\Python35\Scripts)。
  • 从那里你可以使用 pip 安装 whl 文件 pip install C:\Users\USERNAME\Downloads\numpy-1.11.1+mkl-cp35-cp35m-win_amd64.whl