【问题标题】:Autocomplete in embedded IPython嵌入式 IPython 中的自动完成
【发布时间】:2017-04-27 17:15:21
【问题描述】:

我正在使用IPython.terminal.embed 中的InteractiveShellEmbed 将IPython 嵌入到我的应用程序中。一切正常,但自动完成不适用于模块。例如:import rand[TAB] 未完成到 import random。 我该怎么做才能解决这个问题?

我的代码:

# -*- coding: utf-8 -*-
#!/usr/bin/env python

def main():

    from IPython.terminal.embed import InteractiveShellEmbed

    ipshell = InteractiveShellEmbed(banner1 = 'Loading\n',
                                    exit_msg = 'Leaving')


    ipshell('Hit Ctrl-D to exit interpreter.\n')

if __name__ == "__main__":
    main()

【问题讨论】:

    标签: python autocomplete ipython interactive-shell


    【解决方案1】:

    自动完成功能似乎适用于 iPython 5.1.0 和 python 2.7.6。您使用的是哪个版本的 iPython?如果您只是使用“from IPython import embed”然后在您想要的应用程序中调用“embed()”,您是否有同样的问题?

    ---更新:

    尝试创建一个显式实例:

    ipshell = InteractiveShellEmbed.instance()

    【讨论】:

    • 感谢您的回复!我将 IPython 4.2.0 与 Python 3.4.2 一起使用。使用 from IPython 导入嵌入; embed() 自动完成功能正常。问题在于使用 InteractiveShellEmbed。
    • 试试这个:ipshell = InteractiveShellEmbed.instance()
    猜你喜欢
    • 1970-01-01
    • 2014-02-23
    • 2019-04-17
    • 1970-01-01
    • 2013-04-14
    • 2022-10-15
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多