请帮忙:Windows上的Emacs中的IPython崩溃

1 投票
1 回答
1297 浏览
提问于 2025-04-16 05:02

问题更新:为什么没有 In[1]: 提示?

请看下面在 Emacs 中运行 IPython 命令行的输出。

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.


import sys
sys.path
Out[4]: 
['',
 'C:\\Python25\\scripts',
 'C:\\Python25\\lib\\site-packages\\pyflakes-0.4.0-py2.5.egg',
 'C:\\Python25\\lib\\site-packages\\pylint-0.21.3-py2.5.egg',
 'C:\\Python25\\lib\\site-packages\\logilab_astng-0.20.3-py2.5.egg',
 'C:\\Python25\\lib\\site-packages\\logilab_common-0.52.0-py2.5.egg',
 'C:\\Python25\\lib\\site-packages\\unittest2-0.5.1-py2.5.egg',
 'C:\\Python25\\Lib\\site-packages\\pyflakes',
 'C:\\Python25\\Lib\\site-packages\\Pymacs',
 'C:\\Python25\\Lib\\site-packages\\rope',
 'C:\\Python25\\Lib\\site-packages\\ropemacs',
 'C:\\Python25\\Lib\\site-packages\\ropemode',
 'C:\\WINDOWS\\system32\\python25.zip',
 'C:\\Python25\\DLLs',
 'C:\\Python25\\lib',
 'C:\\Python25\\lib\\plat-win',
 'C:\\Python25\\lib\\lib-tk',
 'C:\\Python25',
 'C:\\Python25\\lib\\site-packages',
 'C:\\Python25\\lib\\site-packages\\win32',
 'C:\\Python25\\lib\\site-packages\\win32\\lib',
 'C:\\Python25\\lib\\site-packages\\Pythonwin',
 'C:\\Python25\\lib\\site-packages\\IPython/Extensions',
 u'C:\\Home\\_ipython']

你好,

我正在使用 IPython 0.10、Python 2.5 和 EmacsW32 23.1,以及在 Windows XP 上的 ipython.el Rev.2927。当我在 Emacs 中调用 python-shell 时,它总是崩溃。有人能帮我解决这个问题吗?非常感谢!

更新:我尝试了修复方法 https://bugs.launchpad.net/ipython/+bug/290228,但没有帮助。

IPython 崩溃时出现以下长长的调试信息:

错误:发生了意外错误 在标记输入时。以下 回溯可能已损坏或无效。 错误信息是:('EOF in multi-line statement', (14, 0))

--------------------------------------------------------------------------- 类型错误
Python 2.5.2:C: \Python25\python.exe 2010年9月30日 星期四 14:00:08 发生了一个问题 执行 Python 代码时。这里是导致错误的函数调用序列, 最近的(最内层)调用在最后。

c:\Python25\Scripts\ipython-script.py 在 () 1 2 3 4 5 6 7 ----> 8 global load_entry_point = 9 #!C:\Python25\python.exe 10 # EASY-INSTALL-ENTRY-SCRIPT: 'ipython==0.10','console_scripts','ipython' 11 requires = 'ipython==0.10' 12 import sys 13 from pkg_resources import load_entry_point 14 15 sys.exit( 16 load_entry_point('ipython==0.10', 'console_scripts', 'ipython')() 17 ) 18 19 20 21 22 23 24 25 26 27 28 29 30 31

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\ipapi.pyc 在 launch_new_instance(user_ns=None, shellclass=None) 541 542 def check_hotname(self,name): 543 if name in self.hotnames: 544 self.debug_stack( "HotName '%s' caught" % name) 545 546 547 def launch_new_instance(user_ns = None,shellclass = None): 548 """ 创建并启动一个新的 ipython 实例。 549 550 即使没有已经初始化的 551 ipython 会话运行,也可以调用此函数。 552 553 这也用作 'ipython' 脚本的入口点。 554 555 """ --> 556 ses = make_session(user_ns,shellclass) 557 ses.mainloop() 558 559 560 def make_user_ns(user_ns = None): 561 """返回一个有效的用户交互命名空间。 562 563 这构建了一个字典,包含操作所需的最小信息 作为一个有效的 IPython 用户命名空间,你可以将其传递给 ipython 中的各种嵌入类。 564 565 这个 API 目前已被弃用。请使用 ipapi.make_user_namespaces() 来同时创建 本地和全局命名空间对象。 566 567 :参数: 568 user_ns : 类似字典的,可选

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\ipapi.pyc 在 make_session(user_ns=None, shellclass=None) 669 670 def make_session(user_ns = None, shellclass = None): 671 """创建,但不启动 IPython 会话。 672 673 之后你可以在返回的对象上调用 obj.mainloop()。 674 675 输入: 676 677 - user_ns(None):一个字典,用作用户的命名空间 其中包含初始数据。 678 679 警告:当会话已经存在时,不应运行此操作。""" 680 681 import IPython.Shell 682 if shellclass is None: --> 684 return IPython.Shell.start(user_ns) 685 return shellclass(user_ns = user_ns) 686 687 688 689 690 691 692 693 694 695 696 697 698 699

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\Shell.pyc 在 start(user_ns=None) 1226
th_mode = special_opts.pop() 1227
except KeyError: 1228
th_mode = 'tkthread' 1229
return th_shell[th_mode] 1230
1231 1232 # 这是应该由外部代码调用的。
1233 def start(user_ns = None):
1234 """返回一个运行中的 shell 实例,处理线程选项。 1235 1236 这是一个 工厂函数,将根据用户的线程 选择实例化适当的 IPython shell。
1237 这种选择器是必要的 因为不同的 GUI 工具包需要不同的线程处理细节。""" 1238 1240
shell = _select_shell(sys.argv) -> 1241 return shell(user_ns = user_ns) 1242 1243 # 一些 向后兼容的别名
1244 IPythonShell = IPShell 1245 IPythonShellEmbed = IPShellEmbed
1246 #************ 文件结束 ************* 1247 1248 1249 1250 1251 1252
1253 1254 1255 1256

-----------------------------------------------------------------------------

 62 # This class is trivial now, but I want to have it in to publish a

清理 63 # 接口。稍后当内部结构重新组织时,使用此 64 # 的代码不应更改。 65 66 class IPShell: 67 """创建一个 IPython 实例。""" 68 69 def init(self,argv=None,user_ns=None,user_global_ns=None, 70 debug=1,shell_class=InteractiveShell): 71 self.IP = make_IPython(argv,user_ns=user_ns, 72 user_global_ns=user_global_ns, ---> 73 debug=debug,shell_class=shell_class) global that = undefined global gets = undefined global prepended = undefined global to = undefined global all = undefined global calls = undefined global so = undefined global header = undefined global used = undefined 74 75 def mainloop(self,sys_exit=0,banner=None): 76 self.IP.mainloop(banner) 77 if sys_exit: 78 sys.exit() 79 80

-----------------------------------------------------------------------------

 81 def kill_embedded(self,parameter_s=''):
 82     """%kill_embedded : deactivate for good the current

嵌入式 IPython。 83 84 此函数(在请求确认后)设置一个 内部标志,以便 85 嵌入式 IPython 将不再激活。这是有用的 用于 86 永久禁用在循环中调用的 shell:一旦你 87 从中找到了所需的内容,你可以杀死它, 然后程序将继续运行,而不会再干扰交互式 shell。

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython \ipmaker.pyc 在 make_IPython(argv=[r'c:\Python25\Scripts\ipython- script.py', '-i'], user_ns=None, user_global_ns=None, debug=1, rc_override=None, shell_class=, embedded=False, kw={}) 755 IP_rc.banner = 0 756 if IP_rc.banner: 757 BANN_P = IP.BANNER_PARTS 758 else: 759 BANN_P = [] 760 761 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile) 762 763 # 添加消息日志(可能为空) 764 if msg.summary: BANN_P.append(msg.summary) 765 # 最终横幅是一个字符串 766 IP.BANNER = '\n'.join(BANN_P) 767 768 # 完成 IPython 实例的初始化。这假设 rc 结构已完全 769 # 到位。 --> 770 IP.post_config_initialization() 771 772 return IP 773 #************** 文件结束


774
775
776
777
778
779
780
781
782
783
784
785

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\iplib.pyc 在 post_config_initialization(self=) 847 这是在配置文件处理后调用的 848 '最终' 初始化。""" 849 850 rc = self.rc 851 852 # 对象检查器 853 self.inspector = OInspect.Inspector(OInspect.InspectColors, 854 PyColorize.ANSICodeColors, 855 'NoColor', 856 rc.object_info_string_level) 857 858 self.rl_next_input = None 859 self.rl_do_indent = False 860 # 正确加载 readline 861 if rc.readline: --> 862 self.init_readline() 863 864 # 本地快捷方式,这个使用得很多 865 self.log = self.logger.log 866 867 # 初始化缓存,设置输入/输出提示和打印系统 868 self.outputcache = CachedOutput(self, 869 rc.cache_size, 870 rc.pprint, 871 input_sep = rc.separate_in, 872 output_sep = rc.separate_out, 873 output_sep2 = rc.separate_out2, 874 ps1 = rc.prompt_in1, 875 ps2 = rc.prompt_in2, 876 ps_out = rc.prompt_out, 877 pad_left = rc.prompts_pad_left)

C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\iplib.pyc 在 init_readline(self=) 1476
if not readline.uses_libedit: 1477 for rlcommand in self.rc.readline_parse_and_bind:
1478 #print "loading rl:",rlcommand # 调试 1479 readline.parse_and_bind(rlcommand)
1480 1481 # 从分隔符列表中删除一些字符。如果我们 遇到 1482 # unicode 字符,丢弃它们。 1483
delims = readline.get_completer_delims().encode("ascii", "ignore") 1484 delims = delims.translate(string._idmap,
1485 self.rc.readline_remove_delims)
1486
readline.set_completer_delims(delims) 1487 # 否则我们会在一段时间后得到一个庞大的历史记录: 1488
readline.set_history_length(1000)
1489 try: 1490

print '* 正在读取 readline 历史' # 调试

-> 1491 readline.read_history_file(self.histfile) 1492 except IOError:
1493 pass # 它还不存在。 1494 1495
atexit.register(self.atexit_operations) 1496 del atexit 1497
1498 # 为所有平台配置自动缩进 1499
self.set_autoindent(self.rc.autoindent) 1500 1501 def ask_yes_no(self,prompt,default=True): 1502 if self.rc.quiet: 1503 return True 1504 return ask_yes_no(prompt,default) 1505
1506 def new_main_mod(self,ns=None):

C:\Python25\lib\site-packages\pyreadline\rlmain.pyc 在 read_history_file(self=, filename=u'C:\Home\_ipython\history') 168 169 def set_history_length(self, length): 170 '''设置要保存在历史文件中的行数。 171 172 write_history_file() 使用此值在保存时截断历史文件。 173 负值表示无限历史文件大小。 174 ''' 175 self._history.set_history_length(length) 176 177 def clear_history(self): 178 '''清除 readline 历史''' 179 self._history.clear_history() 180 181 def read_history_file(self, filename=None): 182 '''加载 readline 历史文件。默认文件名是 ~/.history。''' --> 183 self._history.read_history_file(filename) 184 185 def write_history_file(self, filename=None): 186 '''保存 readline 历史文件。默认文件名是 ~/.history。''' 187 self._history.write_history_file(filename) 188 189 # 完成器函数 190 191 def set_completer(self, function=None): 192 '''设置或移除完成器函数。 193 194 如果指定了函数,它将用作新的 完成器函数;如果省略或为 None,则移除任何已安装的完成器函数。完成器函数被称为 195 function(text, state),对于 state 在 0、1、2,...,直到它返回一个 196 非字符串值。它应该返回下一个可能的完成

C:\Python25\lib\site-packages\pyreadline\lineeditor\history.pyc 在 read_history_file(self=, filename=u'C:\Home\_ipython\history') 55 56 history_length=property(get_history_length,set_history_length) 57 history_cursor=property(get_history_cursor,set_history_cursor) 58 59 def clear_history(self): 60 '''清除 readline 历史。''' 61 self.history[:] = [] 62 self.history_cursor = 0 63 64 def read_history_file(self, filename=None): 65 '''加载 readline 历史文件。''' 66 if filename is None: 67 filename=self.history_filename 68 try: 69 for line in open(filename, 'r'): ---> 70 self.add_history(lineobj.ReadLineTextBuffer(ensure_unicode(line.rstrip()))) global n = undefined global Xd = undefined global S = undefined global NR = undefined global i = undefined global R2 = undefined global R = undefined global t = undefined global history_search_forwardt = undefined global history_search_backwardt = undefined global joinR2 = undefined global maxR = undefined global mint = undefined global IndexError = undefined global RX = undefined global partialt = undefined global hcstartt = undefined global hct = undefined global ht = undefined global result = undefined global s = undefined global C = undefined global Python25 = undefined global lib = undefined global site = undefined global packages = undefined global pyreadline = global lineeditor = undefined global history.pyt = undefined global search = undefined global I = undefined global c = undefined global d = undefined global Search = undefined global forward = undefined global through = undefined global the = undefined global history = undefined global string = global of = undefined global characters = undefined global between = undefined global start = undefined global current = undefined line = 'import sys\n' global point.This = undefined global a = undefined global non = undefined global incremental = undefined global search.By = undefined global default = undefined global this = undefined global command = undefined global unbound.i = undefined global Rj = undefined global Re = undefined global q = undefined global history.pyR = undefined global backward = undefined global Rk = undefined global history.pyR = undefined global N = undefined global propertyR = undefined global R4 = undefined global R5 = undefined global R7 = undefined global R8 = undefined global RC = undefined global RD = undefined global R_ = undefined global s.t = undefined

按回车键退出: global _main_t = undefined global aaaat = undefined global aabat = undefined global aacat = undefined global akcat = undefined global bbbt = undefined global ako = undefined global ret = undefined global operatorRS = undefined global sysR = undefined global pyreadline.unicode_helperR = undefined global modulesR = undefined global exceptionst = undefined global ExceptionR = undefined global pyreadline.loggerR = undefined global FalseR9 = undefined global objectR = undefined global RLR = undefined global history.pys = undefined global module = undefined 71 except IOError: 72 self.history = [] 73 self.history_cursor = 0 74 75 def write_history_file(self, filename=None): 76 '''保存 readline 历史文件。''' 77 if filename is None: 78 filename=self.history_filename 79 fp = open(filename, 'wb') 80 for line in self.history[-self.history_length:]: 81 fp.write(ensure_str(line.get_line_text())) 82 fp.write('\n') 83 fp.close() 84 85

C:\Python25\lib\site-packages\pyreadline\unicode_helper.pyc 在 ensure_unicode(text='import sys') 5 # 根据 BSD 许可证的条款分发。完整许可证 在 6 # COPYING 文件中,作为此软件的一部分分发。 7

*******************************************

  8 import sys
  9
 10 try:
 11     pyreadline_codepage=sys.stdout.encoding
 12 except AttributeError:        #This error occurs when pdb imports readline and doctest has replaced
 13                               #stdout with stdout collector
 14     pyreadline_codepage="ascii"   #assume

ascii 代码页 15 16 17 def ensure_unicode(text): 18 """确保传递给 WriteConsoleW 的文本是 unicode 的辅助函数""" 19 if isinstance(text, str): ---> 20 return text.decode(pyreadline_codepage, "replace") 21 return text 22 23 def ensure_str(text): 24 """将 unicode 转换为 str,使用 pyreadline_codepage""" 25 if isinstance(text, unicode): 26 return text.encode(pyreadline_codepage, "replace") 27 return text 28 29 30 31 32 33 34 35

类型错误:decode() 的第一个参数必须是 字符串,而不是 None


哎呀,IPython 崩溃了。我们尽力让它稳定,但...

崩溃报告已自动生成,包含以下信息: - 崩溃回溯的逐字副本。 - 本次会话期间的输入历史记录副本。 - 当前 IPython 配置的数据。

它被保存在名为: 'C:\Home_ipython\IPython_crash_report.txt' 的文件中。 如果你能将此文件发送给开发者,里面的信息将 帮助他们理解和修正这个问题。

你可以发送到:Fernando Perez at fperez....@gmail.com,主题为 'IPython 崩溃报告'。

如果你想现在就发送,以下命令可以工作(在 Unix 下):mail -s 'IPython 崩溃报告' fperez....@gmail.com < C:\Home_ipython \IPython_crash_report.txt

为了确保准确跟踪此问题,请在以下地址提交报告: https://bugs.launchpad.net/ipython/+filebug

1 个回答

3

安装 pyreadline 这个库应该会有所帮助。

撰写回答