简体   繁体   中英

Installing cv2 on linux server

I am trying to opencv ie cv2 on my Linux server which has following configurations.

Linux D07-CPT-8gb-4cpu-nyc1 4.4.0-92-generic #115-Ubuntu SMP Thu Aug 10 09:04:33 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Before trying on the server I tried this command on my Bash for Windows and working fine here.

sudo apt-get install libopencv-dev python-opencv

I ran the same command on Linux server but when I type import cv2 I am getting this error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'cv2'

opencv is not listed when I check with pip freeze. Note: I am using python 3.5.2

At least on Ubuntu 16.04, there exist Python 2 and Python 3 .

So when install package for python, you should be care of your python version. The default python and pip is for Python 2 .

Solutions :

1 . specific the Python version

sudo python3 -m pip install opencv-python 

2 . install python3-pip , and then use python3 and pip3

sudo apt install python3-pip
pip3 install opencv-python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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