I would like to write a Python script in Repl.it, but I can't seem to be able to import OpenCV. I am using Repl.it for the first time, so I am not really sure of what I should be doing.
Here are the different things that I tried :
- Just having
import opencv_python as cv2
in main.py results in the following console output:
Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
Repl.it: Installing fresh packages
Repl.it:
Collecting opencv_python
Using cached https://files.pythonhosted.org/packages/37/49/874d119948a5a084a7ebe98308214098ef3471d76ab74200f9800efeef15/opencv_python-4.0.0.21-cp36-cp36m-manylinux1_x86_64.whl
Collecting numpy>=1.11.3 (from opencv_python)
Using cached https://files.pythonhosted.org/packages/f5/bf/4981bcbee43934f0adb8f764a1e70ab0ee5a448f6505bd04a87a2fda2a8b/numpy-1.16.1-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.16.1 opencv-python-4.0.0.21
Target directory /home/runner/.site-packages/numpy-1.16.1.dist-info already exists. Specify --upgrade to force replacement.
Target directory /home/runner/.site-packages/numpy already exists. Specify --upgrade to force replacement.
Target directory /home/runner/.site-packages/opencv_python-4.0.0.21.dist-info already exists. Specify --upgrade to force replacement.
Target directory /home/runner/.site-packages/cv2 already exists. Specify --upgrade to force replacement.
You are using pip version 9.0.1, however version 19.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Repl.it: package installation success
Traceback (most recent call last):
File "main.py", line 1, in <module>
import opencv_python as cv2
ModuleNotFoundError: No module named 'opencv_python'
It seems the package is installed correctely, but cannot be imported for some reason...?
- I also tried adding a requirements.txt file :
opencv-python==4.0.0.21
but this results in a similar output:
Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
Repl.it: Installing fresh packages
Repl.it:
Collecting opencv-python==4.0.0.21 (from -r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/37/49/874d119948a5a084a7ebe98308214098ef3471d76ab74200f9800efeef15/opencv_python-4.0.0.21-cp36-cp36m-manylinux1_x86_64.whl
Collecting numpy>=1.11.3 (from opencv-python==4.0.0.21->-r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/f5/bf/4981bcbee43934f0adb8f764a1e70ab0ee5a448f6505bd04a87a2fda2a8b/numpy-1.16.1-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.16.1 opencv-python-4.0.0.21
Target directory /home/runner/.site-packages/numpy-1.16.1.dist-info already exists. Specify --upgrade to force replacement.
Target directory /home/runner/.site-packages/numpy already exists. Specify --upgrade to force replacement.
Target directory /home/runner/.site-packages/opencv_python-4.0.0.21.dist-info already exists. Specify --upgrade to force replacement.
Target directory /home/runner/.site-packages/cv2 already exists. Specify --upgrade to force replacement.
You are using pip version 9.0.1, however version 19.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Repl.it: package installation success
Traceback (most recent call last):
File "main.py", line 1, in <module>
import opencv_python as cv2
ModuleNotFoundError: No module named 'opencv_python'
I also tried to import the opencv-python-headless package (both with and without a requirements file), with the same result.
Finally, I tried using the following line in main.py:
import cv2
which results in this output:
Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
Traceback (most recent call last):
File "/run_dir/repl.py", line 60, in <module>
raise EOFError
EOFError
Traceback (most recent call last):
File "main.py", line 1, in <module>
import cv2
File "/home/runner/.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
I would greatly appreciate any help in importing this package!