简体   繁体   English

在 anaconda 中安装 OpenCV 未显示在 Windows 10 的 VS Code 中

[英]Installation of OpenCV in anaconda not showing up in VS Code in Windows 10

I have a VM running only Anaconda.我有一个仅运行 Anaconda 的 VM。 There are no other available installations of Python.没有其他可用的 Python 安装。 This is all I see when I run "Apps and Features" in Windows 10 and filter for Python (note that it is Python 3.7.4):这就是我在 Windows 10 中运行“应用程序和功能”并过滤 Python 时看到的全部内容(请注意,它是 Python 3.7.4):

在此处输入图片说明

When I go to the Conda prompt and enter conda list, I see that I have openCV installed :当我转到 Conda 提示符并输入 conda list 时,我看到我已经安装了 openCV:

在此处输入图片说明

but it's with a version of Python 3.7.6:但它使用的是 Python 3.7.6 版本:

在此处输入图片说明

However when I open VS Code and I set my Python Path to the version in the Anaconda folder: (C:\\Users\\Me\\Anaconda3\\Python.exe) and try to import OpenCV, I get the "module not found" error.但是,当我打开 VS Code 并将 Python 路径设置为 Anaconda 文件夹中的版本时:(C:\\Users\\Me\\Anaconda3\\Python.exe) 并尝试导入 OpenCV,出现“找不到模块”错误。 When I create a new python file and run当我创建一个新的 python 文件并运行时

help("modules")

I do not see OpenCV in the list below in the terminal even though its installed.即使安装了 OpenCV,我也没有在终端下面的列表中看到 OpenCV。

Any idea how this is happening?知道这是怎么发生的吗? I just don't see a second installation of Python on my PC, but why am I seeing 3.7.4 and 3.7.6 and is this possibly causing my issue?我只是没有在我的 PC 上看到第二次安装 Python,但为什么我看到 3.7.4 和 3.7.6,这是否可能导致我的问题?

Edit: Added a picture of the error I get when trying to run it.编辑:添加了我在尝试运行时遇到的错误图片。

在此处输入图片说明

Install anaconda plugin in VSCode and select your conda environment in the bottom left of VSCode window.在 VSCode 中安装 anaconda 插件并在 VSCode 窗口的左下角选择您的 conda 环境。

If you didn't create a conda environment, the you will probably have installed the package in the base environment.如果您没有创建 conda 环境,则您可能已经在基本环境中安装了该软件包。

Edit: Reading the PyPi project , I found the right way to import opencv in python code.编辑:阅读PyPi 项目,我找到了在 python 代码中导入 opencv 的正确方法。

import cv2

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

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