简体   繁体   中英

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

I have a VM running only Anaconda. There are no other available installations of 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):

在此处输入图片说明

When I go to the Conda prompt and enter conda list, I see that I have openCV installed :

在此处输入图片说明

but it's with a version of 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. When I create a new python file and run

help("modules")

I do not see OpenCV in the list below in the terminal even though its installed.

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?

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.

If you didn't create a conda environment, the you will probably have installed the package in the base environment.

Edit: Reading the PyPi project , I found the right way to import opencv in python code.

import cv2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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