python - 请帮助: IPython for Emacs on Windows crashes

标签 python windows emacs ipython

问题更新:为什么没有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崩溃时包含以下冗长的调试信息:

ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (14, 0))

--------------------------------------------------------------------------- TypeError
Python 2.5.2: C: \Python25\python.exe Thu Sep 30 14:00:08 2010 A problem occured executing Python code. Here is the sequence of function calls leading up to the error, with the most recent (innermost) call last.

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-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 in 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 """ Make and start a new ipython instance. 549 550 This can be called even without having an already initialized 551 ipython session running. 552 553 This is also used as the egg entry point for the 'ipython' script. 554 555 """ --> 556 ses = make_session(user_ns,shellclass) 557 ses.mainloop() 558 559 560 def make_user_ns(user_ns = None): 561 """Return a valid user interactive namespace. 562 563 This builds a dict with the minimal information needed to operate as a 564 valid IPython user namespace, which you can pass to the various embedding 565 classes in ipython. 566 567 This API is currently deprecated. Use ipapi.make_user_namespaces() instead 568 to make both the local and global namespace objects simultaneously. 569 570 :Parameters: 571 user_ns : dict-like, optional

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 """Makes, but does not launch an IPython session. 672 673 Later on you can call obj.mainloop() on the returned object. 674 675 Inputs: 676 677 - user_ns(None): a dict to be used as the user's namespace with initial 678 data. 679 680 WARNING: This should not be run when a session exists already.""" 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
except KeyError: 1228
th_mode = 'tkthread' 1229
return th_shell[th_mode] 1230
1231 1232 # This is the one which should be called by external code.
1233 def start(user_ns = None):
1234 """Return a running shell instance, dealing with threading options. 1235 1236 This is a factory function which will instantiate the proper IPython shell
1237 based on the user's threading choice. Such a selector is needed because 1238 different GUI toolkits require different thread handling details.""" 1239 1240
shell = _select_shell(sys.argv) -> 1241 return shell(user_ns = user_ns) 1242 1243 # Some aliases for backwards compatibility
1244 IPythonShell = IPShell 1245 IPythonShellEmbed = IPShellEmbed
1246 #************ End of file ************* 1247 1248 1249 1250 1251 1252
1253 1254 1255 1256

C:\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 # Default timeout for waiting for multithreaded shells (in seconds) 59 GUI_TIMEOUT = 10 60 61

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

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

clean 63 # interface. Later when the internals are reorganized, code that uses this 64 # shouldn't have to change. 65 66 class IPShell: 67 """Create an IPython instance.""" 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

embedded IPython. 83 84 This function (after asking for confirmation) sets an internal flag so that 85 an embedded IPython will never activate again. This is useful to 86 permanently disable a shell that is being called inside a loop: once you've 87 figured out what you needed from it, you may then kill it and the program 88 will then continue to run without the interactive shell interfering again.

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 # add message log (possibly empty) 764 if msg.summary: BANN_P.append(msg.summary) 765 # Final banner is a string 766 IP.BANNER = '\n'.join(BANN_P) 767 768 # Finalize the IPython instance. This assumes the rc structure is fully 769 # in place. --> 770 IP.post_config_initialization() 771 772 return IP 773 #************** end of file


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 This is called after the configuration files have been processed to 848 'finalize' the initialization.""" 849 850 rc = self.rc 851 852 # Object inspector 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 # Load readline proper 861 if rc.readline: --> 862 self.init_readline() 863 864 # local shortcut, this is used a LOT 865 self.log = self.logger.log 866 867 # Initialize cache, set in/out prompts and printing system 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 in 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 # Remove some chars from the delimiters list. If we encounter 1482 # unicode chars, discard them. 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 # otherwise we end up with a monster history after a while: 1488
readline.set_history_length(1000)
1489 try: 1490

print '* Reading readline history' # dbg

-> 1491 readline.read_history_file(self.histfile) 1492 except IOError:
1493 pass # It doesn't exist yet. 1494 1495
atexit.register(self.atexit_operations) 1496 del atexit 1497
1498 # Configure auto-indent for all platforms 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 in read_history_file(self=, filename=u'C:\Home\_ipython\history') 168 169 def set_history_length(self, length): 170 '''Set the number of lines to save in the history file. 171 172 write_history_file() uses this value to truncate the history file 173 when saving. Negative values imply unlimited history file size. 174 ''' 175 self._history.set_history_length(length) 176 177 def clear_history(self): 178 '''Clear readline history''' 179 self._history.clear_history() 180 181 def read_history_file(self, filename=None): 182 '''Load a readline history file. The default filename is ~/.history.''' --> 183 self._history.read_history_file(filename) 184 185 def write_history_file(self, filename=None): 186 '''Save a readline history file. The default filename is ~/.history.''' 187 self._history.write_history_file(filename) 188 189 #Completer functions 190 191 def set_completer(self, function=None): 192 '''Set or remove the completer function. 193 194 If function is specified, it will be used as the new completer 195 function; if omitted or None, any completer function already 196 installed is removed. The completer function is called as 197 function(text, state), for state in 0, 1, 2, ..., until it returns a 198 non-string value. It should return the next possible completion

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 '''Clear readline history.''' 61 self.history[:] = [] 62 self.history_cursor = 0 63 64 def read_history_file(self, filename=None): 65 '''Load a readline history file.''' 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

Press enter to exit: 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 '''Save a readline history file.''' 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 in ensure_unicode(text='import sys') 5 # Distributed under the terms of the BSD License. The full license is in 6 # the file COPYING, distributed as part of this software. 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 codepage 15 16 17 def ensure_unicode(text): 18 """helper to ensure that text passed to WriteConsoleW is 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 text 28 29 30 31 32 33 34 35

TypeError: decode() argument 1 must be string, not None


Oops, IPython crashed. We do our best to make it stable, but...

A crash report was automatically generated with the following information: - A verbatim copy of the crash traceback. - A copy of your input history during this session. - Data on your current IPython configuration.

It was left in the file named: 'C:\Home_ipython\IPython_crash_report.txt' If you can email this file to the developers, the information in it will help them in understanding and correcting the problem.

You can mail it to: Fernando Perez at fperez....@gmail.com with the subject 'IPython Crash Report'.

If you want to do it now, the following command will work (under Unix): mail -s 'IPython Crash Report' fperez....@gmail.com < C:\Home_ipython \IPython_crash_report.txt

To ensure accurate tracking of this issue, please file a report about it at: https://bugs.launchpad.net/ipython/+filebug

最佳答案

安装pyreadline应该会有所帮助。

关于python - 请帮助: IPython for Emacs on Windows crashes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3867236/

相关文章:

emacs - 使用 Emacs 缩进(移位 4)代码

python - SQL 到 SQLAlchemy 的翻译

python - 如何在 Windows 上运行介子构建系统?

c# - DatagridView 复选框已选中?

emacs - elisp 表达式 (1+ (buffer-size)) 和 (+ 1 (buffer-size)) 是什么意思?

regex - 如何禁用 Emacs 正则表达式替换的这个 'feature'(不需要的大写)

python - 代码优化: How to optimize a code using scipy minimize?

python - 转到上一个用户输入是用户输入指定的字符串

python - 获取当前 GTK 主题的字体颜色

c++ - C++ 中的自定义文件扩展名