简体   繁体   English

即使Anaconda说它已安装,导入Numpy也会导致错误?

[英]Importing Numpy results in error even though Anaconda says it's installed?

I signed up for a statistics udemy course which uses jupyter running the stock numpy package out of anaconda. 我注册了一个统计学的udemy课程,该课程使用jupyter运行anaconda的stock numpy包。

Numpy is working when I run python 3.4.4 in pycharm, but it will not work in either anaconda2 nor anaconda3.. this makes no sense because numpy comes stock as part of the anaconda library. 当我在pycharm中运行python 3.4.4时,Numpy正在工作,但它在anaconda2和anaconda3中都无法工作..这没有任何意义,因为numpy作为anaconda库的一部分出现了库存。

When I try importing numpy in jupyter, running a local instance of a python 2 script, I get this: 当我尝试在jupyter中导入numpy,运行python 2脚本的本地实例时,我得到: jupyter错误消息的屏幕截图

Thinking I could sidestep the error using a IDE, I tried pycharm and I got this: 我想我可以使用IDE来回避错误,我尝试了pycharm,我得到了这个:

sreenshot of pycharm错误消息

Numpy is part of the anaconda default library which I'm running, so I checked and made sure the numpy package was there via the Anaconda Prompt using 'conda list'... Numpy是我正在运行的anaconda默认库的一部分,所以我检查并确保通过使用'conda list'的Anaconda Prompt存在numpy包...

显示所有包的anaconda提示的屏幕截图

Why won't it import successfully? 为什么不能成功导入?

Before I uninstall and reinstall everything, does anyone have any ideas? 在我卸载并重新安装所有内容之前,有没有人有任何想法?

Yayyyy. Yayyyy。 I figured it out. 我想到了。 So I had several different python versions before I was running python through anaconda/jupyter. 所以在我通过anaconda / jupyter运行python之前,我有几个不同的python版本。 As a result, the tethering in-between the additional package libraries to the version of python running was shifty. 结果,附加包库之间的绑定与python运行的版本很差。 For example, I may have had numpy working configured to 3.4 but not 2.7.. 例如,我可能已将numpy工作配置为3.4但不是2.7 ..

anyways, to break down the steps I took, I uninstalled all instances of python (both anaconda and normal versions). 无论如何,为了打破我采取的步骤,我卸载了所有python实例(包括anaconda和普通版本)。 Then I deleted the old 3.4 libraries from my C drive. 然后我从C盘中删除了旧的3.4库。 Then I installed anaconda 2.7.11 again, tested importing numpy and got the same error. 然后我再次安装了anaconda 2.7.11,测试了导入numpy并得到了同样的错误。 Then I thought to myself, what if the packages are installed separate from the python library and their configuration didn't get reset via the reinstall.. so via the anaconda prompt I typed: 然后我想,如果软件包与python库分开安装,并且它们的配置没有通过重新安装重置,那该怎么办...所以通过anaconda提示我键入:

pip uninstall numpy

which removed the package I was having trouble with. 这删除了我遇到麻烦的包裹。 and then : 接着 :

pip install numpy

which downloaded and reset a whole new instance of the package. 下载并重置了一个包的全新实例。 Then I tested importing numpy in both the anaconda prompt and jupyter = both worked. 然后我在anaconda提示符和jupyter =两者都测试中测试了导入numpy。

I'm very happy that this ended up working out as I can continue on as planned. 我很高兴这最终得到了解决,因为我可以按计划继续。 For anyone else who experiences a similar problem, I would try uninstalling, then reinstalling the problem causing package via pip commands - this step seemed to have the most impact on fixing the problem. 对于遇到类似问题的其他人,我会尝试卸载,然后通过pip命令重新安装问题导致包 - 这一步似乎对修复问题影响最大。 Then if that doesn't work proceed to uninstall and reinstall the environments in intervals. 然后,如果这不起作用,请继续按间隔卸载并重新安装环境。

You can try using the following command: 您可以尝试使用以下命令:

pip install numpy --upgrade

This will uninstall old installed version of numpy and install a new version. 这将卸载旧安装的numpy版本并安装新版本。 This command solved my issue. 这个命令解决了我的问题。

try activating you base conda environment before starting jupyter. 尝试在启动jupyter之前激活基础conda环境。

>activate root
>jupyter notebook

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入 numpy 时出错,即使我安装正确 - Error importing numpy even though I installed it properly 即使 conda 说已安装 Numpy 也无法导入 - Numpy can't import even though conda says installed 即使已安装,导入 matplotlib 也会出错 - Importing matplotlib gives error even though installed Visual Studio 表示即使安装了 psutil 模块也未找到 - Visual studio says psutil module not found even though it's installed pynput 即使已安装也不导入 - pynput not importing even though it is installed Django 说 Pillow 没有安装,即使它是 - Django says Pillow is not installed even though it is 即使我安装了 Flask 也没有导入 - Flask is not importing even though I installed it 即使 pip 说它已安装,Python 也无法导入 gdal - ubuntu hirsute & impish specific - Python can't import gdal even though pip says it's installed - ubuntu hirsute & impish specific 导入错误:Anaconda numpy(numpy和Anaconda已安装,virtualenv) - Import error: Anaconda numpy (numpy and Anaconda already installed, virtualenv) Pycharm 抛出:ModuleNotFoundError: No module named 'numpy' 错误即使安装了 Numpy - Pycharm throws: ModuleNotFoundError: No module named 'numpy' error even though Numpy is installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM