简体   繁体   English

无法在 Python 中导入 OpenCv 模块

[英]Cannot import OpenCv module in Python

I try to run the python script using OpenVINO, so I write "setupvars" and run a script by command line as "python main.py".我尝试使用 OpenVINO 运行 python 脚本,因此我编写了"setupvars"并通过命令行将脚本运行为“python main.py”。

It tells me this:它告诉我:

Traceback (most recent call last): File "main.py", line 1, in import cv2 ImportError: DLL load failed while importing cv2: Module not found.回溯(最近一次调用):导入 cv2 中的文件“main.py”第 1 行 ImportError:导入 cv2 时 DLL 加载失败:找不到模块。 If I run the script not initializing OpenVINO如果我运行的脚本没有初始化 OpenVINO

It works properly.它工作正常。 What is my problem, guys?伙计们,我的问题是什么?

Thank you for your answers谢谢您的回答

Can you show us your python setup?你能告诉我们你的python设置吗?

try:尝试:

python3 --version

and then try然后尝试

pip3 freeze

If you do not see opencv in that list, it means it was not installed properly.如果您在该列表中没有看到 opencv,则表示它没有正确安装。

I had the same issue as I was using Python 3.8+ and apparently they don't support that.我在使用 Python 3.8+ 时遇到了同样的问题,显然他们不支持。 Right now OpenVINO supports only from 3.5-3.7.目前 OpenVINO 仅支持 3.5-3.7。

Also, you should not need to install the opencv again using the pip install command.此外,您不需要再次使用 pip install 命令安装 opencv。 If anything, you should reinstall the OpenVINO toolkit again after you got Python 3.7 or so installed.如果有的话,您应该在安装 Python 3.7 左右后再次重新安装 OpenVINO 工具包。 (You can reinstall by re-running the toolkit installer again). (您可以通过再次重新运行工具包安装程序来重新安装)。

You need to install OpenCV module at python terminal go to the window termianal and command你需要在 python 终端安装 OpenCV 模块去窗口终端和命令

'''
pip install opencv-python
'''

then you can try your script again然后你可以再次尝试你的脚本

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

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