在python空闲错误中导入openCV:共享对象文件

问题描述 投票:0回答:3

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

当我输入import cv2时,我得到了:

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

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

opencv raspberry-pi3 python-idle
3个回答
0
投票

遵循opencv和面部识别的命令:(它对我有用)

-> sudo apt update

-> sudo apt upgrade

-> sudo apt-get install python3-pip

pi@raspberrypi:~ $ python3 -V
Python 3.5.3
pi@raspberrypi:~ $ python2 -V
Python 2.7.13

-> pip3 install numpy

-> pip3 install pillow

-> pip3 install dlib

-> sudo apt-get install cmake

-> pip3 install face_recognition

-> sudo apt-get install python-opencv

-> sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev

-> sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

-> sudo apt-get install libatlas-base-dev

-> sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev -y

-> sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y

-> sudo apt-get install libgtk2.0-dev libgtk-3-dev -y

-> sudo pip3 install opencv-python

-> sudo apt-get install libavformat-dev libswscale-dev openexr libopenexr-dev

-> sudo apt-get install libqt4-dev

-> sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev



pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> import dlib
>>> import face_recognition
>>> 

取决于系统。进行PI需要2到3个小时。 (总时间)

感谢:)


0
投票

如讨论的here,以下安装似乎可以解决该问题。它对我有用。

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

0
投票

[由python3的opencv docs“ https://docs.opencv.org/4.2.0/d2/de6/tutorial_py_setup_in_ubuntu.html”给出的在Linux上安装opencv的推荐方法是:

sudo apt install python3-opencv

对于python2:

sudo apt install python-opencv

在Raspberry pi上,您有时可能需要运行:

sudo apt update --fix-missing

它将自动安装所有依赖项。

© www.soinside.com 2019 - 2024. All rights reserved.