티스토리 뷰

OpenCV

ubuntu에 opencv 설치

BaeZzang22 2022. 8. 4. 14:49

처음 설치할때는 

pip3 install opencv-python # 주요 모듈 설치
pip3 install opencv-contrib-python # 주요 및 추가 모듈 설치

#또는
python -m pip install opencv-python
python -m pip install opencv-contrib-python

그런데, 서버에 opencv가 설치된 줄 알았는데, 확인해보니 importError가 났다. 

(제대로 설치가 안된거지..)

 

importerror: libavformat.so.58: cannot open shared object file: no such file or directory

(구글링 했을 때, 57,56은 나오던데, 어쨌든 file이나 directory가 없다는 거니까..)

whereis libavformat.so.58

libavformat dependency 설치

sudo apt-get install libavformat-dev

그리고 다시 reload.. 그러나 또 에러,,. 다시 opencv install을 해도 

$ sudo apt-get install python-opencv
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-opencv

검색, 검...새..ㄱ.. 거,,,,ㅁ,ㅅ ㅐ,,,ㄱ  

어쨋든,, 제대로 설치가 안됐다..

sudo apt-get install python3-opencv

 

기쁜 마음으로..다시 시작 (아직 시작도 못했다...)

이번엔 다른 에러가 

 

ImportError: numpy.core.multiarray failed to import

numpy 버전 문제인 것 같아,, upgrade를 했다. 

sudo -H pip3 install --upgrade pip
pip3 install --upgrade numpy

드디어 start 


이번엔 다른 ip에 opencv 설치하다가 다른 에러 발생!! 위에 있는 에러처럼 필요한 dependency들이 없어서 생기는 에러같다. 그래서 추가 설치를 해줬다. 

ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

 

stackoverflow 의 솔루션대로 install하면 정상작동하는데,

sudo apt-get install libatlas-base-dev
sudo apt-get install libhdf5-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libjasper-dev 
sudo apt-get install libqt4-test

 

중간에 설치하다가 

E: Package 'libqtgui4' has no installation candidate 이런식으로 메세지가 뜨고 설치가 fail되서 또 찾아봤는데, 

버전 업그레이드 해서 install 하라고 한다.  

sudo apt-get install libqt5gui5 libqt5webkit5 libqt5test5

 

 

이외에, 필요했던 라이브러리

pip3 install pillow

 

다시, 설치과정을 겪다 보니 결론! 

다른 블로그들에 있는 것처럼 처음부터 다 설정을 잡아가면서 설치할 거 아니면, (pip로 install 하려면) 

opencv, pip, numpy, dependency, 필요한 이외의 라이브러리 등을 설치해주고, 에러메세지 확인하면서 더 필요한 부분을 설치해주면 될 것 같다. 

 

 

참고 사이트

 

How to upgrade pip3?

I want to use python3.5 for development, but many times when I install the module for python 3.5, it always fails. The terminal tells me that a higher version is available, but it doesn't work when I

stackoverflow.com

 

[Numpy 설치 후 Import Error] Import Error: numpy.core.multiarray failed to import

Import Error: numpy.core.multiarray failed to import 저 같은 경우에는 PyTorch를 import할 때, 위와 같은 에러가 발생하였는데요. 이는 PyTorch 내부에서 Numpy를 불러올 때, 버전 차이 문제때문에 발생..

wsshin.tistory.com

 

How can I install python-opencv package in Ubuntu 20.04?

I am trying to install python-opencv. I can see a distribution for Ubuntu 18.04 right here: https://packages.ubuntu.com/bionic/python-opencv Unfortunately, Ubuntu 20.04 can't see it: $ sudo apt-get

askubuntu.com

 

ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

I am trying to run an Arducam MT9J001 camera on a raspberry pi 3b+. I am getting the following error when I try to run the program, "ImportError: libcblas.so3: cannot open shared object file: No such

stackoverflow.com

 

Libqtgui4 is not available (Has no installation candidate)

I am trying to run this command: $ sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5 But I receive these errors: Package libqtgui4 is not available, but is referred to by another

raspberrypi.stackexchange.com

 

 

'OpenCV' 카테고리의 다른 글

window에서 opencv 설치  (0) 2022.08.03
Create chessboard pattern  (0) 2022.07.06
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함