我可以在python交互式shell中导入cv2,但如果我运行python脚本,则说没有名为cv2的模块

时间:2016-11-07 15:51:19

标签: python opencv

当我在python交互式shell中导入cv2时:

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print cv2.__version__
2.4.8
>>> 

但是当我运行这段代码时:

import cv2
print (cv2.__version__)

有错误说:

Traceback (most recent call last):
  File "/home/ubuntu/workspace/test.py", line 1, in <module>
    import cv2 as cv
ImportError: No module named 'cv2'

为什么会这样?

0 个答案:

没有答案