我成功编译并安装了OpenCV 4.5.0,但是当我使用python3导入cv2时,我发现cv2的版本是4.5.1。类似于以下输出:
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.getBuildInformation())
General configuration for OpenCV 4.5.1 =====================================
Version control: 4.5.1-dirty
Platform:
Timestamp: 2021-01-02T12:47:39Z
Host: Linux 5.4.0-54-generic aarch64
CMake: 3.18.4
CMake generator: Unix Makefiles
CMake build tool: /bin/gmake
Configuration: Release
.........
Python 3:
Interpreter: /opt/python/cp36-cp36m/bin/python (ver 3.6.12)
Libraries: libpython3.6m.a (ver 3.6.12)
numpy: /tmp/pip-build-env-c03ewnak/overlay/lib/python3.6/site-packages/numpy/core/include (ver 1.19.3)
install path: python
Python (for build): /bin/python2.7
Install to: /tmp/pip-req-build-zuuo394f/_skbuild/linux-aarch64-3.6/cmake-install
-----------------------------------------------------------------
当我打开/tmp
时,我找不到文件夹/pip-req-build-zuuo394f
。
但是当我使用python(2.7.17)时,我得到了正确的opencv版本:
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.getBuildInformation())
General configuration for OpenCV 4.5.0 =====================================
Version control: unknown
Extra modules:
Location (extra): /home/xana/opencv_contrib/modules
Version control (extra): unknown
Platform:
Timestamp: 2021-04-07T04:04:29Z
Host: Linux 4.9.140-tegra aarch64
CMake: 3.10.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: RELEASE
.......
cuDNN: YES (ver 8.0.0)
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.17)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.17)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
install path: lib/python2.7/dist-packages/cv2/python-2.7
Python 3:
Interpreter: /usr/bin/python3 (ver 3.6.9)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.9)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.13.3)
install path: lib/python3.6/dist-packages/cv2/python-3.6
Python (for build): /usr/bin/python2.7
Install to: /usr
-----------------------------------------------------------------
在Python2的cv2中,cv2中的所有函数都可以正常工作。那么,如何在python3中更改cv2版本呢?非常感谢!
发布于 2021-04-08 10:14:53
我遵循@Peter的建议print(cv2)
。我在/home/.local/lib/python3.6/site-packages/cv2
文件夹中找到了一个cv2.so,但我的OpenCV 4.5.0安装在usr/lib/python3.6/dist-packages/cv2
中。
然后,我删除了/home/...
中的cv2文件夹,并再次使用import cv2
,cv2.__version__
现在是4.5.0版本,所有功能都正常工作。
https://stackoverflow.com/questions/66987356
复制相似问题