IPython选项卡仅完成部分模块

发布于 2024-08-07 05:15:28 字数 1179 浏览 5 评论 0原文

我正在使用 EPD 版本的 python 和 IPython。使用 easy_install 安装一些模块后,我注意到,虽然可以导入它们,但无法使用 Tab 键完成它们。它们存在于路径中,但是虽然包含的模块(pylab、readline、math)可以完成,但这些新模块却不能。

有人知道我应该检查什么才能找到问题吗?我已经检查过这些包是否与其他模块位于同一位置:

In [1]: import pylab

In [2]: pylab
Out[2]: <module 'pylab' from '/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/pylab.pyc'>

In [3]: import BeautifulSoup

In [4]: BeautifulSoup
Out[4]: <module 'BeautifulSoup' from '/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/BeautifulSoup-3.1.0.1-py2.5.egg/BeautifulSoup.pyc'>

也许有些东西没有正确处理 .eggs ?谢谢。

更新:在 gnibbler 的帖子之后,我发现 tab 补全在completer.py 的第 633 行遇到了异常:

    try:
        ret = self.matches[state].replace(magic_prefix,magic_escape)
        return ret
    except IndexError:
        return None

但是是什么导致了失败...

更新:

In [5]: from Bea<tab_here>
*** COMPLETE: <Bea> (0)
matches: []
state: 0

所以这只是说匹配列表是一个空集:没有匹配。仍然没有找到该模块。当我有时间的时候,我会尝试调查 matches 在哪里获取它正在寻找的模块。

I'm using the EPD version of python and IPython. After installing some modules using easy_install I notice that, although they can be imported, they cannot be tab completed. They exist on the path but, while included modules (pylab, readline, math) can be completed, these new modules cannot.

Anyone know what I should look into to find the problem? I've checked that the packages are in the same place as other modules:

In [1]: import pylab

In [2]: pylab
Out[2]: <module 'pylab' from '/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/pylab.pyc'>

In [3]: import BeautifulSoup

In [4]: BeautifulSoup
Out[4]: <module 'BeautifulSoup' from '/Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/BeautifulSoup-3.1.0.1-py2.5.egg/BeautifulSoup.pyc'>

Maybe something not handling the .eggs correctly? Thanks.

Update: Following up on gnibbler's post, I've found that the tab completion hits an exception at line 633 in completer.py at:

    try:
        ret = self.matches[state].replace(magic_prefix,magic_escape)
        return ret
    except IndexError:
        return None

But what is causing the failiure...

Update:

In [5]: from Bea<tab_here>
*** COMPLETE: <Bea> (0)
matches: []
state: 0

So this is just saying that the matches list is an empty set: there are no matches. It is still not finding the module. I'll try to investigate where matches is getting the modules its looking for when I have time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

御守 2024-08-14 05:15:28

在我厌倦了这种行为后,昨天我找到了这个问题的答案。

看起来 IPython 有一个简单的数据库,其中包含它可以在 sys.path 中找到的所有模块。每次安装新模块时,您都必须编写魔法,

In [1]: %rehashx

以便 IPython 重新生成其数据库。然后你就可以用 TAB 补全新模块了。

I found an answer to this question yesterday, after I got tired of this behavior.

It seems that IPython has a simple database with all the modules it can find in sys.path. Every time you install a new module you have to write the magic

In [1]: %rehashx

so that IPython regenerates its database. Then you can have TAB-completion of new modules.

感情洁癖 2024-08-14 05:15:28

Ipython/completer.py 的末尾是以下代码:


        except:
            #from IPython.ultraTB import AutoFormattedTB; # dbg
            #tb=AutoFormattedTB('Verbose');tb() #dbg
# If completion fails, don't annoy the user. return None

也许取消注释会给你一个线索

right at the end of Ipython/completer.py is this code:


        except:
            #from IPython.ultraTB import AutoFormattedTB; # dbg
            #tb=AutoFormattedTB('Verbose');tb() #dbg
# If completion fails, don't annoy the user. return None

Perhaps uncommenting it will give you a clue

恋竹姑娘 2024-08-14 05:15:28

本地安装的非egg模块在导入时可以通过制表符完成名称,但egg模块则不能(IPython 0.10、Python 2.6) .2、Mac OS X)。

我建议使用 IPython 提交功能请求/错误报告!

Locally installed, non-egg modules can have their name tab-completed, when doing import, but egg modules cannot (IPython 0.10, Python 2.6.2, Mac OS X).

I would suggest to file a feature request / bug report with IPython!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文