本文介绍了在python空闲错误中导入openCV:共享对象文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在 python 中使用 cv2 库(在 raspberry pi 3 的 IDLE 中),但我无法成功导入它.

当我输入 import cv2 时,我得到这个:

回溯(最近一次调用最后一次):文件/home/pi/Desktop/python/test.py",第 2 行,在 <module> 中从 .cv2 导入 *导入错误:libjasper .so.1:无法打开共享对象文件:没有这样的文件或目录

我使用终端来更新、升级和安装 opencv 以及我能找到的几乎所有其他与 opencv 或 lib 相关的东西.我目前可以在终端中导入 cv2 但不能在 IDLE 中导入.我需要做什么才能导入 cv2 库?提前致谢.

解决方案

这里所讨论的

a>,下面的安装似乎解决了这个问题.它对我有用.

pip3 安装 opencv-python须藤 apt-get 安装 libatlas-base-dev须藤 apt-get 安装 libjasper-dev须藤 apt-get 安装 libqtgui4须藤 apt-get 安装 python3-pyqt5须藤 apt-get 安装 libqt4-test

较新的 OpenCV 版本自行处理其他安装.

pip install opencv-python==4.1.2.30

I have been trying to use the cv2 library in python (in IDLE on raspberry pi 3) but I can't manage to import it successfully.

when I type import cv2, I get this:

Traceback (most recent call last):
File "/home/pi/Desktop/python/test.py", line 2, in <module>
from .cv2 import *
ImportError: libjasper .so.1: cannot open shared object file: No such file or directory

I have used the terminal to update, upgrade, and install opencv along with pretty much every other thing I could find relating to opencv or lib. I currently can import cv2 in the terminal but not in IDLE. What do I need to do to be able to import the cv2 library? Thanks in advance.

As discussed here, below installations seemed to resolve the issue. It worked for me.

pip3 install opencv-python
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
sudo apt-get install libqtgui4
sudo apt-get install python3-pyqt5
sudo apt-get install libqt4-test

Or

the newer OpenCV version handles other installations themselves.

pip install opencv-python==4.1.2.30

这篇关于在python空闲错误中导入openCV:共享对象文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:12