我似乎无法安装 numpy

I can't seem to install numpy

我尝试安装 numpy,但每当我启动我的程序时,我都会收到这些消息。

Error importing numpy: you should not try to import numpy from
    its source directory; please exit the numpy source tree, and relaunch
    your python interpreter from there.
Traceback (most recent call last):
File "C:\Python34\numpy\__init__.py", line 155, in <module>
from numpy.__config__ import show as show_config
ImportError: No module named 'numpy.__config__'

我不明白不从源目录导入 numpy 是什么意思。我应该从哪里导入它?

错误如其所言。当您在命令行上 运行 python 时,您可能处于 C:\Python34C:\Python34\numpy 中。切换到另一个目录(例如 C:\)和 运行 python,然后尝试 import numpy 看看会发生什么。

根据您的评论,您似乎没有正确安装 numpy,只是将其解压缩到您的 C:\Python34 目录中。安装此模块的最简单方法是访问 Christoph Gohlke's Python Extension Packages for Windows Repository and go down to numpy。下载适用于您的 Python 版本(32 位或 64 位)的 cp34 文件。然后,在命令行上,切换到您的下载目录和 运行,例如

pip install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl

(如果您下载了 64 位版本),它应该安装得很好。如果 pip 出现 Command not found 错误,请确保将 C:\Python34\Scripts 添加到 PATH 环境变量中。完成后,重新启动命令行,它应该可以正常工作。

Gohlke 有大量 Python 的预编译模块,主要与科学计算有关,我总是在使用 pipPyPI 安装之前先检查那里。