简体   繁体   English

Miniconda“安装”numpy但Python无法导入它

[英]Miniconda “installs” numpy but Python can't import it

So I have been having some trouble with this. 所以我一直遇到麻烦。 I need to use numpy so that I can use OpenCV and so I installed Miniconda (Not Miniconda3 because we are working in Python 2.7) and I installed numpy with conda install numpy and it worked because when I run conda list I see that it is there: 我需要使用numpy以便我可以使用OpenCV,所以我安装了Miniconda(不是Miniconda3,因为我们在Python 2.7中工作)并且我安装了numpy和conda install numpy并且它有效,因为当我运行conda list我发现它在那里:

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\joe30_000>conda list
# packages in environment at C:\Users\joe30_000\Miniconda:
#
conda                     3.17.0                   py27_0
conda-env                 2.4.2                    py27_0
menuinst                  1.0.4                    py27_0
numpy                     1.9.3                    py27_0
pip                       7.1.2                    py27_0
pycosat                   0.6.1                    py27_0
pycrypto                  2.6.1                    py27_3
python                    2.7.10                        0
pyyaml                    3.11                     py27_2
requests                  2.7.0                    py27_0
setuptools                18.3.2                   py27_0
wheel                     0.26.0                   py27_1

C:\Users\joe30_000>

And as you can see it is installed for Python 2.7. 正如您所看到的,它是为Python 2.7安装的。 However, when I go to the python command line and try import numpy I get the error that no module exists: 但是,当我转到python命令行并尝试import numpy我得到的错误是没有模块存在:

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>

Why is this happening? 为什么会这样? Do I have to somehow sync Conda with Python so that Python is using the modules that Miniconda has installed? 我是否必须以某种方式将Conda与Python同步,以便Python使用Miniconda已安装的模块?

So thanks to @Bubbafat, I found the solution and I want to post it in case anyone else has problems. 所以感谢@Bubbafat,我找到了解决方案,我想发布它以防其他人有问题。 Like Bubbafat said, conda has its own version of the Python interpreter. 就像Bubbafat所说,conda有自己的Python解释器版本。 It is located in the Miniconda directory (It's called "Python.exe"). 它位于Miniconda目录(它被称为“Python.exe”)。 If you are using an IDE you need to switch the interpreter to use this version of Python rather than the default one you may have installed on the internet from the Python website itself. 如果您使用的是IDE,则需要切换解释器以使用此版本的Python,而不是您可能已从Python网站本身安装在Internet上的默认版本。 I hope this was helpful. 我希望这可以帮到你。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM