今天尝试在docker容器中安装OpenCV,按照习惯,正常使用pip安装:
pip install opencv-python
可以用
pip install-i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
更换清华源安装;
如果出现time out 报错,可以用--default-timeout=100
来解决。
但是当我们一切安装完成之后,在import cv2
时会报错:
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
【解决办法】
直接卸载先前安装的opencv-python
pip uninstall opencv-python
再重新安装opencv-python-headless
:
pip install opencv-python-headless
问题完美解决