22

How should I solve this error in Ubuntu16.04?

    import cv2
  File "/opt/conda/envs/pytorch-py3.6/lib/python3.6/site-packages/cv2/__init__.py", line 3, in <module>
    from .cv2 import *
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
Mona Jalal
  • 4,695
  • 21
  • 74
  • 102

4 Answers4

41

Try this:

sudo apt-get install libglib2.0-0

Then, run your command again. If that doesn't do the trick, try this:

sudo apt-get install libglib2.0-0:i386

I'm on a 64-bit computer, but the tool I'm using uses 32-bit.

Janin
  • 511
1

In my case (on NixOS, but should work for other distros as well) it was enough to install the headless version:

pip uninstall opencv-python
pip install opencv-python-headless
tturbo
  • 141
0

Try to install

apt-get install libgtk2.0-dev

worked for me.

0

@Janin answer worked for me however I needed to first run apt-get update -y. I assume this is because I was running in a container with perhaps a different version of Ubuntu.

Full solution -

apt-get update -y
apt-get install libglib2.0-0
Zach
  • 1
  • 1