2011-03-28 7 views
6

IPython v0.11 (Python 2.6.1 사용)로 전환하기 전에, 예를 들어 this을 사용하여 대화 형 IPython 쉘을 임베드 할 수있었습니다.IPython의 임베디드 대화 형 쉘

from IPython.Shell import IPShellEmbed 
ipshell = IPShellEmbed() 
ipshell() # this call anywhere in your program will start IPython 

는 "내장 쉘 라는 의 진정한 독립 서브 클래스 InteractiveShell으로 리팩토링 된이을 InteractiveShellEmbed. 모든 내장 로직이 포함 된 서브 클래스에 기본 클래스에서 꺼내 넣어왔다"(here을보고 here). 우리가

IPython.embed(exit_msg='Whatever') 
에 의해 exit_msg에 대한 문자열을 전달하면

이제 단순히 그러나

import IPython 
IPython.embed() 

하여 콘솔을 시작할 수 있어야 내가 그것을 이해하는 방법은,이

TraitError: The 'exit_msg' trait of an InteractiveShellEmbed instance must be a string, but a value of u'' was specified.

를 제기

그런 다음 다른 오류가 발생합니다.

AttributeError: 'InteractiveShellEmbed' object has no attribute 'set_completer'

다른 사람이이 문제를 겪었습니까? 결국 이것은 개발자 버전이므로 버그 일 수 있습니다.

from IPython.frontend.terminal.ipapp import TerminalIPythonApp 
app = TerminalIPythonApp.instance() 
app.initialize(argv=[]) # argv=[] instructs IPython to ignore sys.argv 
app.start() 

답변

3

은 GitHub의 위키에 specific instructions 있습니다

from IPython import embed; embed() 

재귀 IPython 다른 IPython 쉘 (내장 의미하는 경우), 이것이 지원되지 않는 오랜 시간이 있었지만 그 문제는 작년에 패치되었습니다.

9

요즘 (3.0 이상) 당신이 할 필요가있다 :