问题更新:为什么没有 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']
你好,
我在 Windows XP 上使用 IPython 0.10、Python 2.5 和 EmacsW32 23.1 和 ipython.el Rev.2927。当我在 Emacs 中调用 python-shell 时,它总是崩溃。有人可以帮助解决这个问题吗?非常感谢!
更新:我已经尝试修复https://bugs.launchpad.net/ipython/+bug/290228,但它没有帮助。
IPython 崩溃并显示以下长调试信息:
错误:标记输入时发生意外错误以下回溯可能已损坏或无效错误消息是:('EOF in multi-line statement', (14, 0))
-------------------------------------------------- ------------------------- TypeError
Python 2.5.2: C: \Python25\python.exe Thu Sep 30 14:00:08 2010 一个问题发生执行 Python 代码。这是导致错误的函数调用序列,最近的(最里面的)调用最后。c:\Python25\Scripts\ipython-script.py in () 1 2 3 4 5 6 7 ----> 8 global load_entry_point = 9 #!C:\Python25\python.exe 10 # EASY-INSTALL-ENTRY-脚本: 'ipython==0.10','console_scripts','ipython' 11需要= 'ipython==0.10' 12 从 pkg_resources 导入 sys 13 import load_entry_point 14 15 sys.exit( 16 load_entry_point('ipython==0.10', '控制台脚本','ipython')()17)18 19 20 21 22 23 24 25 26 27 28 29 30 31
562 563 这构建了一个字典,其中包含作为 564 有效 IPython 用户命名空间运行所需的最少信息,您可以将其传递给 ipython 中的各种嵌入 565 类。566 567 此 API 目前已弃用。使用 ipapi.make_user_namespaces() 而不是 568 同时创建本地和全局命名空间对象。569 570:参数:571 user_ns:类似字典,可选 562 563 这构建了一个字典,其中包含作为 564 有效 IPython 用户命名空间运行所需的最少信息,您可以将其传递给 ipython 中的各种嵌入 565 类。566 567 此 API 目前已弃用。使用 ipapi.make_user_namespaces() 而不是 568 同时创建本地和全局命名空间对象。569 570:参数:571 user_ns:类似字典,可选
C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\ipapi.pyc in 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 682 import IPython.Shell 683 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 in start(user_ns=None) 1226
th_mode = special_opts.pop() 1227
除了 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。这样的选择器是需要,因为 1238 个不同的 GUI 工具包需要不同的线程处理细节。""" 1239 1240
shell = _select_shell(sys.argv) -> 1241 return shell(user_ns = user_ns) 1242 1243 # 向后兼容的一些别名
1244 IPythonShell = IPShell 1245 IPythonShellEmbed = IPShellEmbed
1246 # * ** * ** * ** * ** End of文件 * ** * ** * ** * ** * 1247 1248 1249 1250 1251 1252
1253 1254 1255 1256C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\Shell.pyc in init (self=, argv=None, user_ns=None, user_global_ns=None, debug=1, shell_class= ) 58 # 等待多线程 shell 的默认超时时间(以秒为单位) 59 GUI_TIMEOUT = 10 60 61
-------------------------------------------------- --------------------------
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 prepend = 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 弄清楚你需要什么,你就可以杀死它,然后程序 88 将继续运行,而交互式 shell 不会再次干扰.
C:\Python25\lib\site-packages\ipython-0.10-py2.5.egg\IPython\ipmaker.pyc in 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 in post_config_initialization(self=) 847 配置文件处理完成后调用 848 'finalize' 初始化.""" 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 =无 859 self.rl_do_indent = False 860 # 正确加载 readline 861 if rc.readline: --> 862 self.init_readline() 863 864 # 本地快捷方式,这是一个 LOT 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 # dbg 1479 readline.parse_and_bind(rlcommand)
1480 1481 # 从分隔符列表中删除一些字符。如果我们遇到 1482 # unicode 字符,丢弃它们。第1483
章 delims = readline.get_completer_delims().encode(“ascii”,“忽略”)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: 1490print ' *读取 readline 历史记录' # dbg
-> 1491 readline.read_history_file(self.histfile) 1492 除了 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 返回 True 1504 返回 ask_yes_no(prompt,default) 1505
1506 def new_main_mod(self,ns=None):C:\Python25\lib\site-packages\pyreadline\rlmain.pyc in 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 '''清除读行历史记录''' 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 #Completer functions 190 191 def set_completer(self, function=None): 192 '''设置或移除完成函数。193 194 如果指定了函数,它将作为新的完成者 195 函数;如果省略或无,则删除已安装 196 的任何完成函数。完成者函数称为 197 函数(文本,状态),用于状态 0、1、2、.. ., 直到它返回一个 198 非字符串值。它应该返回下一个可能的完成
C:\Python25\lib\site-packages\pyreadline\lineeditor\history.pyc in 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 如果文件名是 None: 67 filename=self.history_filename 68 try: 69 for line in open(filename, 'r'): ---> 70自己。add_history(lineobj.ReadLineTextBuffer(ensure_unicode(line.rstrip()))) 全局 n = 未定义的全局 Xd = 未定义的全局 S = 未定义的全局 NR = 未定义的全局 i = 未定义的全局 R2 = 未定义的全局 R = 未定义的全局 t = 未定义的全局 history_search_forwardt = 未定义的全局 history_search_backwardt = 未定义的全局 joinR2 = 未定义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 = 未定义全局站点 = 未定义的全局包 = 未定义的全局 pyreadline = 全局 lineeditor = 未定义的全局 history.pyt = 未定义的全局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 = 未定义的全局未绑定。i = 未定义的全局 Rj = 未定义的全局 Re = 未定义的全局 q = 未定义的全局 history.pyR= 未定义的全局后向 = 未定义的全局 Rk = 未定义的全局 history.pyR = 未定义的全局 N = 未定义的全局属性 R = 未定义的全局 R4 = 未定义的全局 R5 = 未定义的全局 R7 = 未定义的全局 R8 = 未定义的全局 RC = 未定义的全局 RD = 未定义的全局 R_ = 未定义的全局 st = 未定义
按回车退出: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 如果文件名是 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) 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) 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 in 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 """Convert unicode to str using pyreadline_codepage""" 25 if isinstance(text, unicode): 26 return text.encode(pyreadline_codepage, "replace") 27 return文字 28 29 30 31 32 33 34 35
TypeError: decode() 参数 1 必须是字符串,而不是 None
糟糕,IPython 崩溃了。我们尽最大努力使其稳定,但是...
使用以下信息自动生成崩溃报告: - 崩溃回溯的逐字副本。- 在此会话期间您的输入历史记录的副本。- 有关您当前 IPython 配置的数据。
它留在名为:'C:\Home_ipython\IPython_crash_report.txt'的文件中。如果您可以将此文件通过电子邮件发送给开发人员,其中的信息将帮助他们理解和纠正问题。
您可以将其邮寄给:Fperez 的 Fernando Perez....@gmail.com,主题为“IPython 崩溃报告”。
如果您现在想这样做,以下命令将起作用(在 Unix 下): mail -s 'IPython Crash Report' fperez....@gmail.com < C:\Home_ipython \IPython_crash_report.txt
为确保准确跟踪此问题,请在以下位置提交报告: https ://bugs.launchpad.net/ipython/+filebug