Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error importing cv2 in python3, Anaconda

I get the following error when importing opencv in python:

> python
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0: undefined symbol: hb_buffer_set_cluster_level

The system is Linux debian 4.7.0-1-amd64, stretch. I have created an environment for Python 3 in Anaconda:

conda create --name=envPython3 python=3 anaconda
source activate envPython3

and then installed OpenCV:

conda install -c https://conda.anaconda.org/menpo opencv3

It should be installed because

conda list | grep cv

returns

opencv3          3.1.0         py35_0    menpo

Everything works fine with Python 2

May be this post is related

like image 275
krasin Avatar asked Oct 12 '16 22:10

krasin


People also ask

How do I fix import cv2 error?

The Python "ModuleNotFoundError: No module named 'cv2'" occurs when we forget to install the opencv-python module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install opencv-python command.

How do I use cv2 in Python 3?

Start the Python shell by typing python3 and then hit enter. You will be inside the Python shell where you can execute your Python code. Import the cv2 package which is the name of the OpenCV module. Type “import cv2” and hit enter.


2 Answers

i also had the same issue. I found an answer that may work for you. Try

source activate envPython3
conda install -c asmeurer pango
python
>>> import cv2

Please see this github link

like image 191
Sam Hammamy Avatar answered Sep 21 '22 15:09

Sam Hammamy


Try again by installing

conda install -c https//conda.binstar.org/menpo opencv3

like image 39
Sabbir Bin Azad Avatar answered Sep 18 '22 15:09

Sabbir Bin Azad