已安装OpenCV,但未找到模块"cv2".在IDLE中 [英] Installed OpenCV but no module found "cv2" in IDLE
问题描述
多年来,我一直在尝试安装OpenCV,最后我成功使用了本教程:
I have been trying to install OpenCV for ages now and finally I succeeded using this tutorial: http://www.pyimagesearch.com/2016/12/05/macos-install-opencv-3-and-python-3-5/.
但是,每当我尝试在IDLE中导入cv2时,都找不到它,但是我确定我安装了OpenCV.
However, whenever I try to import cv2 in IDLE, it is not found but I am certain I installed OpenCV.
cv2.so文件位于: /usr/local/lib/python3.5/site-packages/cv2.so
The cv2.so file exists at: /usr/local/lib/python3.5/site-packages/cv2.so
我相信它可能与解释器有关,但是我不确定如何解决它.在终端中,当我尝试导入它时,它可以工作.我包括了终端消息来证明这一点.
I believe it may have something to do with the interpreter but I am not sure how to fix it. In terminal, when I try importing it, it works. I included the terminal message to prove it.
感谢您的帮助.谢谢.
推荐答案
好,我找到了答案!使用以下方法激活虚拟环境后:
ok i found the answer! after you activate the virtual environment with:
work on cv
在终端上键入此代码以使用当前虚拟环境打开IDLE
type this on the terminal to open the IDLE with the current virtual environment
python -c "from idlelib.PyShell import main; main()"
或
python -m idlelib
它将成功!
这篇关于已安装OpenCV,但未找到模块"cv2".在IDLE中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!