No module named 'cv2' even installed already in conda list

huangapple go评论108阅读模式
英文:

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 &quot;c:\Users\geode\MIA\MIA.py&quot;, line 1, in &lt;module&gt;
    import cv2
ModuleNotFoundError: No module named &#39;cv2&#39;

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),就像这样:

No module named 'cv2' even installed already in conda list

如果你不在基础环境中,并且创建了一个新的环境,你可以通过输入以下命令来检查是否安装了OpenCV:

conda list | grep opencv

你应该能看到它已安装:

No module named 'cv2' even installed already in conda list

你还可以确认环境使用的可执行文件:

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:

No module named 'cv2' even installed already in conda list

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:

No module named 'cv2' even installed already in conda list

also you can confirm the executable being used by the environment with this

python -c "import sys; print(sys.executable)"

No module named 'cv2' even installed already in conda list

This shows your environment is set up properly. If you need more information about managing environments there are good instructions here.

huangapple
  • 本文由 发表于 2023年4月11日 13:10:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75982571.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定