Import from ipython

匿名 (未验证) 提交于 2019-12-03 01:05:01

问题:

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?



文章来源: Import from ipython
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!