“ipython”选项卡自动完成功能不适用于导入的模块
IPython 上的制表符补全似乎不起作用。例如,
import numpy
numpy.<tab>
简单地添加一个选项卡。
import numpy
num<tab>
也只是添加一个选项卡。您能否建议一些可能导致此问题的原因?我运行的是 Windows 7 和 Python 2.6.5。
Tab completion on IPython seems not to be working. For example,
import numpy
numpy.<tab>
simply adds a tab.
import numpy
num<tab>
just adds a tab, too. Could you please suggest some possible causes for this problem? I am running Windows 7 and Python 2.6.5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(19)
确保您已安装 pyreadline 库。制表符补全和其他 IPython 功能需要它 - 在 Windows 中它不附带 IPython 包,您必须单独安装它 -
Be sure you have installed the pyreadline library. It is needed for tab completion and other IPython functions - in Windows it doesn't come with the IPython package and you have to install it separately -
如果有人使用最新的
7.19.0
并且自动完成功能不起作用,请尝试将jedi
降级到0.17.2
:请参阅 https://github.com/ipython/ipython/issues/12740 了解详细信息。
In case anyone is using the recent
7.19.0
and autocomplete does not work, try downgradingjedi
to0.17.2
:See https://github.com/ipython/ipython/issues/12740 for details.
并且
当前带有 Jupyter 笔记本的 Ipython 不需要 jedi.. 所以你必须使用上面的命令卸载它。
我从这里得到它。
and
The current Ipython with the Jupyter notebook doesn't require jedi.. So you have to just uninstall it with the above command.
I got it from here.
pip
告诉我我安装了 pyreadline 版本 1.7.1升级
pyreadline
为我修复了它:pip
told me I had pyreadline version 1.7.1 installedUpgrading
pyreadline
fixed it for me:您的 ipythonrc 文件可能已过期。
尝试跑步
Your ipythonrc file may be out of date.
Try running
降级 iPython 就可以了。
Downgrading iPython did the trick.
我遇到了这个问题。
我通过降级 python-parso 包解决了
降级 python-parso 包(0.8.0-1 => 0.6.2-1)
I had this problem.
I solved by downgrade the python-parso package
downgrading the python-parso package (0.8.0-1 => 0.6.2-1)
经典的“你是否尝试过将其关闭然后再次打开”对我有用。
The classic 'have you tried turning it off and on again' worked for me.
这绝对应该有效,因为它在我的情况下有效
This should definitely work as it worked in my case
截至目前,在 OSX 上,pip 安装的 ipython 不提供制表符补全,pyreadline release.py 已损坏.. 什么 WFM:
YMMV。
As of right now, on a OSX, pip installed ipython doesn't give tab completion, pyreadline release.py is busted .. what WFM:
YMMV.
StackOverflow 中的其他人发布了此链接: http://www.vankouteren.eu/blog/2009/06/getting-ipython-readline-and-auto-completion-to-work-on-mac-os-x/
基本上,
easy_install readline
就是发现 readline Egg 的安装位置并编辑 ipython bin 脚本以使用此 readline:easy_install readline
/Library/Python/site-packages/readline-*.egg
或在 Virtualenv 对应项中which ipython
import sys
行之后添加 readline Egg 路径。我的 virtualenved ipython bin 脚本工作如下:
Someone else in StackOverflow posted this link: http://www.vankouteren.eu/blog/2009/06/getting-ipython-readline-and-auto-completion-to-work-on-mac-os-x/
Its basicly
easy_install readline
than discover where the readline egg got installed and edit the ipython bin script to use this readline:easy_install readline
/Library/Python/site-packages/readline-*.egg
or in your Virtualenv counterpartwhich ipython
import sys
line.My virtualenved ipython bin script got working as follow:
我意识到这是一个非常老的问题,但是上面的答案都不适合我(这是当你用谷歌搜索这种性质的问题时得到的第一个结果)。
我应该提到这并不是 Windows 所独有的,我在运行 CentOS 6.5 和 Python 2.7 时遇到了问题,
这就是我所做的:
如果您没有 -devel 软件包,那么在链接它们时您的安装将失败,并且建造鸡蛋..希望这对其他人有帮助!
I realize this is a really old question, but none of the answers above worked for me (And this is the first hit you get when you google a question of this nature).
I should mention that this is NOT exclusive to windows, I had the problem running CentOS 6.5 and Python 2.7
Here is what I did:
If you don't have the -devel packages, your install will fail when it comes time to link them and build the eggs.. Hope this helps others!
我遇到了这个问题,并且知道我已经为我正在寻找的模块安装了 pip。执行 $ ipython --init 解决了我的问题。
I had this problem and knew that I had the pip installed for the module I was looking for. Performing
$ ipython --init
solved the problem for me.在我的例子中,我必须
mv ~/.ipython{,.bak}
。I had to
mv ~/.ipython{,.bak}
in my case.如果您使用 Jupyter 笔记本,并且在尝试了此处帖子中建议的所有步骤后仍然可以使用 Tab 自动完成功能,则您可能需要检查是否尝试在函数定义中使用 Tab 自动完成功能。如果您的导入语句是如下函数的一部分,您将无法获得 Tab 自动完成功能。您需要将导入语句放在函数外部,并在要求包自动完成之前执行一次。
If you use Jupyter notebook and you still did get Tab auto-complete working after you tried all the steps suggested in the post here, you might want to check if you are trying to use the Tab auto-completion within a function definition. Ifyour import statements are part of the function such as below, you will not get the Tab auto-completion. You need to put the import statements outside the function and also execute them once before asking for auto-completion on the packages.
我在使用 numpy 库时遇到了同样的问题。该问题与 ipython 或 jupyter 笔记本的特定版本有关,只需更新 ipython 或 jupyter 即可解决。
如果您使用的是 anaconda 或 miniconda 这样的 conda 环境,则使用 anaconda 来更新该环境中的 ipython
如果使用 anaconda,您还需要更新 qtconsole 有时
anaconda 限制 ipython 的更新,然后尝试
如果您不使用环境,则直接使用 更新点
I faced the same problem with the numpy library. The issue is with the particular version of ipython or jupyter notebook and it is resolved by simply updating ipython or jupyter.
If you are using a conda environment like anaconda or miniconda then update ipython in that environment by using
In case of anaconda you also need to update the qtconsole
Sometimes anaconda constraints the update of ipython then try
If you are not using a environment then directly update using pip
我通过安装 jedi-language-server 解决了我的问题:
PS,我在虚拟环境中从 Conda 安装了 Ipython,并在激活环境时使用了上述命令。
I solved my issue by installing jedi-language-server:
PS, I was installed Ipython from Conda in a virtual env and used the above command when the env was activated.
要检查 ipython 及其使用的模块是否匹配,请运行
pip check ipython
。对于我在 2021 年 7 月使用 ipython 7.25 进行的配置,这给出了一个很好的明确警告:
您当然可能会看到不同的警告——
这只是一个示例,与制表符补全无关。
然后降级它,例如
pip install 'importlib-metadata<4'
# 不要忘记“引号”Also useful:
pip list
-- $PYTHONPATH 中的所有内容,以及版本和位置pip check
-- 所有内容pip show ipython --
但要查看所需的版本,您必须查看
.../site-packages/ipython-*.dist-info/METADATA
To check if ipython and the modules it uses match, run
pip check ipython
.For my configuration with ipython 7.25 in July 2021, this gave a good clear warning:
You may of course see different warnings --
this is just an example, unrelated to tab completion.
Then to downgrade it, e.g.
pip install 'importlib-metadata<4'
# don't forget the 'quotes'Also useful:
pip list
-- everything in your $PYTHONPATH, with version and locationpip check
-- everythingpip show ipython
--but to see the required versions you have to look at
.../site-packages/ipython-*.dist-info/METADATA
ipython 需要 Pyreadline。安装 pyreadline。这是在 Windows 7 中完成的。获取 pyreadline zip,pyreadline-master.zip,解压缩。在 powershell 中将目录更改为压缩的 pyreadline,确保在 Path 中设置 python,然后输入命令
python setup.py install
这会将 pyreadline 安装在 C:\Python27\Lib\site-packages 中Pyreadline is needed by ipython. Install pyreadline. This was done in Windows 7. Get pyreadline zip, pyreadline-master.zip, unzip. In powershell change directory into uzipped pyreadline, make sure python is set in Path, and enter command
python setup.py install
This will intall pyreadline in C:\Python27\Lib\site-packages