Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: libavcodec.so.57: cannot open shared object file: No such file or directory

I am working on a python project and I am sadly experienced that once I attempt to run the script from the PyCharm ide I get the following error message:

from .cv2 import *
ImportError: libavcodec.so.57: cannot open shared object file: No such file or directory

Now running the same python script from terminal runs without any error so I feel pretty confident that every requirement is installed properly. Therefore I turned my attention to environment variables but I am not completely sure what should the name and value be of the variable I am supposed to add to pycharm environment variable list. I run the following command:

whereis libavcodec.so.57

and I got:

libavcodec.so: /usr/lib/x86_64-linux-gnu/libavcodec.so.57 /usr/lib/x86_64-linux-gnu/libavcodec.so

So I guess that has something to do with the the value of the env variable I am supposed to add to PyCharm.

Can anybody help me how to solve this?

like image 609
DalekSupreme Avatar asked Nov 07 '22 13:11

DalekSupreme


1 Answers

This is because of the way you install the openCV.

Try the following command to install openCV correctly:

$ sudo apt-get remove python-opencv; sudo apt-get install python-opencv
like image 130
Pedram Avatar answered Nov 15 '22 05:11

Pedram