我想在Repl.it中编写一个Python脚本,但似乎无法导入OpenCV。我是第一次使用Repl.it,所以我不确定自己应该做什么。
这是我尝试过的不同事情:
import opencv_python as cv2main.py中的
会导致以下控制台输出:
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'
似乎软件包安装正确,但是由于某种原因无法导入...?
opencv-python==4.0.0.21
但这会导致类似的输出:
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'
我还尝试导入opencv-python-headless软件包(带有和不带有需求文件),结果相同。
最后,我尝试在main.py中使用以下行:
import cv2
这将导致以下输出:
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
在导入此程序包方面的任何帮助,我将不胜感激!