【问题标题】:Irregular module detection/autocompletion in IPythonIPython中的不规则模块检测/自动完成
【发布时间】:2013-06-05 06:49:25
【问题描述】:

(检查编辑以获得更好的解释)

(屏幕截图是 pycharm 中使用 ipython 的内置 python 控制台。如果我也单独使用 ipython,也会存在同样的问题。 在 IPython 控制台中,如果我键入 from gi.repository import 并按 Tab 键查看可用选项,我看不到任何这些模块(Glib、RB、Gtk、Gio 等)。但如果我执行from gi.repository import RB 或Gtk 等,它会起作用!即使它不应该根据我的自动完成列表。 然后,如果我输入 from gi.repository import 并按 Tab,我会看到我之前导入的模块。与列表中的任何其他模块相同。 为什么会这样?它导致 PyCharm 中错误报告的错误(如您在屏幕截图中所见)。

编辑:为了更好地说明问题:

明白我的意思了吗?起初它只显示RB 和absolute_import 作为选项。我仍然能够导入Gtk。之后,它显示了更多选项。仍然不是完整的模块列表。

【问题讨论】:

    标签: python ipython


    【解决方案1】:

    将该目录添加为“源”内容根目录。

    http://www.jetbrains.com/pycharm/webhelp/configuring-content-roots.html

    pycharm autosuggest 将开始显示建议。

    【讨论】:

    • 但是这个问题并不是 Pycharm 特有的。它也发生在纯 ipython 上。我只是放了 pycharm 的屏幕截图,因为它使用了 ipython,这就是我发现问题的方式。
    【解决方案2】:

    重建可用模块列表:%rehashx cf %rehashx?,最后一段。

    Update the alias table with all executable files in $PATH.
    
    This version explicitly checks that every entry in $PATH is a file
    with execute access (os.X_OK), so it is much slower than %rehash.
    
    Under Windows, it checks executability as a match against a
    '|'-separated string of extensions, stored in the IPython config
    variable win_exec_ext.  This defaults to 'exe|com|bat'.
    
    This function also resets the root module cache of module completer,
    used on slow filesystems.
    

    【讨论】:

    • 不,它似乎没有解决任何问题。请检查编辑以更好地解释问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-27
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    • 2010-09-20
    • 1970-01-01
    相关资源
    最近更新 更多