使用os.dup2()后,iPython将不再启动

时间:2014-10-27 12:28:44

标签: crash ipython

我正在尝试使用os.dup2()函数重定向输出,当我输入os.dup2(3,1)时,我的ipython(2.7)似乎并不喜欢。 它崩溃了,现在又不会重新开始,产生错误:

Traceback (most recent call last):
  File "/usr/bin/ipython", line 8, in <module>
    launch_new_instance()
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 402, in launch_new_instance
    app.initialize()
  File "<string>", line 2, in initialize
  File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 312, in initialize
    self.init_shell()
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 332, in init_shell
    ipython_dir=self.ipython_dir)
  File "/usr/lib/python2.7/dist-packages/IPython/config/configurable.py", line 318, in instance
    inst = cls(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/interactiveshell.py", line 183, in __init__
user_module=user_module, custom_exceptions=custom_exceptions
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 456, in __init__
    self.init_readline()
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 1777, in init_readline
    self.refill_readline_hist()
  File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 1789, in refill_readline_hist
    include_latest=True):
  File "/usr/lib/python2.7/dist-packages/IPython/core/history.py", line 256, in get_tail
    return reversed(list(cur))
DatabaseError: database disk image is malformed

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

重新作为答案:

看起来fd 3就是您的IPython历史数据库,并且您将stdout重定向到它并使其损坏。

要让它重新开始,请删除或重命名~/.ipython/profile_default/history.sqlite(或Linux上某些IPython版本上的~/.config/ipython/profile_default/history.sqlite。)