英文:
No module named 'cv2' even installed already in conda list
问题
Traceback (most recent call last
):
File "c:\Users\geode\MIA\MIA.py", line 1, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
我已经多种方式安装了opencv2,但它显示没有安装成功。
我已经移除了所有opencv模块
并输入:
[conda install -c conda-forge opencv]
当前的conda列表:
numpy 1.22.3 py310hed7ac4c_2
opencv 4.7.0 py310h5588dad_2
py-opencv 4.7.0 py310hbbfc1a7_2
英文:
Traceback (most recent call last
):
File "c:\Users\geode\MIA\MIA.py", line 1, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
I have installed opencv2 in several ways, but it says it is not there.
I already removed all opencv modules
and typed:
[conda install -c conda-forge opencv]
present conda list
numpy 1.22.3 py310hed7ac4c_2
opencv 4.7.0 py310h5588dad_2
py-opencv 4.7.0 py310hbbfc1a7_2
答案1
得分: 1
这可能与环境设置有关。你是在基础环境中安装还是新建了一个环境?如果是在基础环境中,确保你运行以下命令:
conda activate base
应该在提示符中的任何信息之前显示(base)
,就像这样:
如果你不在基础环境中,并且创建了一个新的环境,你可以通过输入以下命令来检查是否安装了OpenCV:
conda list | grep opencv
你应该能看到它已安装:
你还可以确认环境使用的可执行文件:
python -c "import sys; print(sys.executable)"
这显示你的环境已正确设置。如果需要更多关于管理环境的信息,可以查看这里的详细说明。
英文:
I think this may have something to do with the environment setup. Did you install it in the base environment, or a new one? If in the base, make sure you run
conda activate base
it should say (base) before any information in the prompt, like this:
if you are not in the base environment, and you created a new one, you can see if it's installed by typing
conda list | grep opencv
and you should see it installed:
also you can confirm the executable being used by the environment with this
python -c "import sys; print(sys.executable)"
This shows your environment is set up properly. If you need more information about managing environments there are good instructions here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论