-2

I have written a python code in which I am using opencv-python. The code is perfectly running on my local machine. I am trying to make it live by uploading it on a server.

File "/var/www/xxxx/xxxxx/xxxxx/imgmask.py", line 2, in import cv2 as cv from .cv2 import * ImportError: libGL.so.1: cannot open shared object file: No such file or directory

How can I resolve this problem? Please help!!

Note: I am using windows 10.

  • Have you installed opencv-python on the server? – Tristen Mar 20 '21 at 06:23
  • I am so glad to see your comment. And yes, I did. But I think there are 2-3 versions of python installed on server. I don't think it must be creating a problem, Is it? – Devansh Gawai Mar 20 '21 at 06:26
  • Maybe take a look at this: https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo – Tristen Mar 20 '21 at 06:28
  • Okay, I will check it. Should I run that command to install it globally or in specific folder? – Devansh Gawai Mar 20 '21 at 06:32

2 Answers2

0

If you use pipenv, you should write on terminal: pip install opencv-python

Frightera
  • 2,334
  • 2
  • 7
  • 16
0

In the file you are importing cv2 copy the following code and paste and run it.

try:
   import cv2
except Exception as e:
   from pip._internal import main
   main(["install", "opencv-python"])
finally:
   pass

Good Luck, let me know if it works

Crispen Gari
  • 1,343
  • 9
  • 12