Python 导入错误:没有名为 numpy Anaconda 的模块

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

Import Error: No module named numpy Anaconda

pythonnumpyanacondaconda

提问by penny

I have a very similar question to this question. I have only one version of python 3.5 installed on my Windows 7 64-bit system. I installed Anaconda3.4 via official website - as suggested in the question. The installation went fine but when I want to import(I just typing python from the command line )

我有一个与这个问题非常相似的问题。我的 Windows 7 64 位系统上只安装了一个版本的 python 3.5。我通过官方网站安装了 Anaconda3.4 - 正如问题中所建议的。安装进行得很顺利,但是当我想导入时(我只是从命令行输入 python )

import numpy

Import error:No module named numpy

Then I exit and type

然后我退出并输入

pip install numpy 

Requirement already satisfied (use --upgrade to upgrade): numpy in d:\program fi les\anaconda3\lib\site-packages

需求已经满足(使用--upgrade升级):numpy in d:\program file\anaconda3\lib\site-packages

I know this is probably a super basic question, but I'm still learning... Thanks

我知道这可能是一个超级基本的问题,但我仍在学习......谢谢

回答by JoshAdel

If you are using Anaconda3 then you should already have numpy installed. There is no reason to use pip. My guess is that the Anaconda distribution is possibly not on your path and you are picking up some other system python.

如果您使用的是 Anaconda3,那么您应该已经安装了 numpy。没有理由使用pip. 我的猜测是 Anaconda 发行版可能不在您的路径上,而您正在选择其他一些系统 python。

You should run where python(or where python3) to see which one you are using. If the executable is not in the Anaconda install, then that is your problem and you will need to edit your path environment variable to ensure that you are opening the python you want.

您应该运行where python(或where python3) 以查看您使用的是哪一种。如果可执行文件不在 Anaconda 安装中,那么这是您的问题,您需要编辑路径环境变量以确保您正在打开所需的 python。

回答by Shivam Mishra

Anaconda installs python with it so whenever you are running python, you need to make sure you are using the one which anaconda installed. Use this command to know which python executable you are using right now. Keep the one installed by anaconda(typically inside anaconda folder) and uninstall any other.

Anaconda 随它安装了 python,因此无论何时运行 python,您都需要确保使用的是 anaconda 安装的那个。使用此命令可了解您现在正在使用的 Python 可执行文件。保留 anaconda 安装的那个(通常在 anaconda 文件夹中)并卸载其他任何一个。

    where python

回答by vlbthambawita

First, remove the numpy from anaconda:

首先,从 anaconda 中删除 numpy:

conda remove numpy

conda 删除 numpy

Then, install it back using pip

然后,使用 pip 重新安装它

pip install numpy

pip 安装 numpy

This works for me.

这对我有用。

回答by earnshae

It is possible that numpy is not installed in the virtual environment that you are using at runtime, but may be installed as part of the global anaconda install.

numpy 可能未安装在您在运行时使用的虚拟环境中,但可能作为全局 anaconda 安装的一部分进行安装。

From the terminal first activate the enviroment.

从终端首先激活环境。

$ source activate {your environment name}

Then install numpy with conda install

然后用 conda install 安装 numpy

$ conda install numpy

I found that this was the case with an environment that I had created with pycharm.

我发现我用 pycharm 创建的环境就是这种情况。

Installing it locally corrected the issue.

在本地安装它更正了问题。