gpt4 book ai didi

python - 导入错误 : No module named cv2 with Python 2. 7

转载 作者:太空宇宙 更新时间:2023-11-03 23:17:43 27 4
gpt4 key购买 nike

这是我做的

import cv2
import sys
sys.path.append('/usr/include/opencv')

im = cv2.imread("im1.png")
print type(im)

然后终端给我

  File "m7.py", line 1, in <module>
import cv2
ImportError: No module named cv2

好像是安装在这里

 pkg-config opencv --cflags
-I/usr/include/opencv
whereis opencv
opencv: /usr/include/opencv /usr/share/opencv

我在 build 中的文件列表

3rdparty  CMakeCache.txt       cmake_uninstall.cmake    cvconfig.h  include  Makefile  OpenCVConfig.cmake          unix-install
apps CMakeFiles CPackConfig.cmake data junk modules OpenCVConfig-version.cmake version_string.tmp
bin cmake_install.cmake CPackSourceConfig.cmake doc lib opencv2 OpenCVModules.cmake

最佳答案

尝试在导入 cv 模块之前添加路径。

import sys
sys.path.append('/usr/include/opencv')
import cv2

问候

关于python - 导入错误 : No module named cv2 with Python 2. 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36428655/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com