问题
If I use IDLE with python 2.7
import cv
import cv2
and it works
but if I use ipython notebook
it gives me error
ImportError Traceback (most recent call last) in () ----> 1 import cv
ImportError: No module named cv
So how to use OpenCV from iPython?
EDIT:
from IDLE
['', 'C:\Python27\Lib\idlelib', 'C:\Python27\lib\site-packages\pip-1.1-py2.7.egg', 'C:\Python27\lib\site-packages\gensim-0.8.6-py2.7.egg', 'C:\WINDOWS\system32\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', 'C:\Python27\lib\plat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27', 'C:\Python27\lib\site-packages', 'C:\Python27\lib\site-packages\PIL']
from ipython anaconda
['', 'C:\Anaconda\python27.zip', 'C:\Anaconda\DLLs', 'C:\Anaconda\lib', 'C:\Anaconda\lib\plat-win', 'C:\Anaconda\lib\lib-tk', 'C:\Anaconda', 'C:\Anaconda\lib\site-packages', 'C:\Anaconda\lib\site-packages\PIL', 'C:\Anaconda\lib\site-packages\win32', 'C:\Anaconda\lib\site-packages\win32\lib', 'C:\Anaconda\lib\site-packages\Pythonwin', 'C:\Anaconda\lib\site-packages\setuptools-0.6c11-py2.7.egg-info', 'C:\Anaconda\lib\site-packages\IPython\extensions']
so the questions seems to be how to install opencv in ipython anaconda? (and why it doesn't use standard python packages)
回答1:
is your PYTHONPATH different in ipython and IDLE? try the following
import sys
print(sys.path)
I suspect the two won't match. have you launched IDLE and ipython from the same terminal?
来源:https://stackoverflow.com/questions/17851503/import-from-ipython