IPython选项卡仅完成一些模块 [英] IPython tab completes only some modules

查看:138
本文介绍了IPython选项卡仅完成一些模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EPD版本的python和IPython。使用easy_install安装一些模块之后我注意到,尽管可以导入它们,但它们不能完成选项卡。它们存在于路径上但是,虽然包含模块(pylab,readline,math)可以完成,但这些新模块不能。

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'>

可能正确处理 .eggs 的事情?谢谢。

Maybe something not handling the .eggs correctly? Thanks.

更新:关注gnibbler的帖子后,我发现标签完成功能在完成后的第633行遇到异常at:

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

但是导致失败...

更新

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.

推荐答案

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

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

似乎IPython有一个简单的数据库它可以在 sys.path 中找到的模块。每次安装新模块时,你都必须写下魔法

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

以便IPython重新生成其数据库。然后你可以让TAB完成新的模块。

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

这篇关于IPython选项卡仅完成一些模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆