“ipython”选项卡自动完成功能不适用于导入的模块

发布于 2024-08-28 13:17:18 字数 232 浏览 6 评论 0原文

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 技术交流群。

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

发布评论

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

评论(19

拿命拼未来 2024-09-04 13:17:18

确保您已安装 pyreadline 库。制表符补全和其他 IPython 功能需要它 - 在 Windows 中它不附带 IPython 包,您必须单独安装它 -

> pip install pyreadline

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 -

> pip install pyreadline
吹梦到西洲 2024-09-04 13:17:18

如果有人使用最新的 7.19.0 并且自动完成功能不起作用,请尝试将 jedi 降级到 0.17.2

pip install 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 downgrading jedi to 0.17.2:

pip install jedi==0.17.2

See https://github.com/ipython/ipython/issues/12740 for details.

自找没趣 2024-09-04 13:17:18
pip uninstall jedi --yes

并且

pip install pyreadline

当前带有 Jupyter 笔记本的 Ipython 不需要 jedi.. 所以你必须使用上面的命令卸载它。

我从这里得到它。

pip uninstall jedi --yes

and

pip install pyreadline

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.

风启觞 2024-09-04 13:17:18

pip 告诉我我安装了 pyreadline 版本 1.7.1

C:\Users\me>pip freeze | grep readline
pyreadline==1.7.1

升级 pyreadline 为我修复了它:

C:\Users\me>pip install --upgrade pyreadline

C:\Users\me>pip freeze | grep readline
pyreadline==2.0

pip told me I had pyreadline version 1.7.1 installed

C:\Users\me>pip freeze | grep readline
pyreadline==1.7.1

Upgrading pyreadline fixed it for me:

C:\Users\me>pip install --upgrade pyreadline

C:\Users\me>pip freeze | grep readline
pyreadline==2.0
℡Ms空城旧梦 2024-09-04 13:17:18

您的 ipythonrc 文件可能已过期。
尝试跑步

ipython -upgrade

Your ipythonrc file may be out of date.
Try running

ipython -upgrade
淡淡の花香 2024-09-04 13:17:18

降级 iPython 就可以了。

pip install --upgrade ipython==5.8.0

Downgrading iPython did the trick.

pip install --upgrade ipython==5.8.0
上课铃就是安魂曲 2024-09-04 13:17:18

我遇到了这个问题。
我通过降级 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)

千鲤 2024-09-04 13:17:18

经典的“你是否尝试过将其关闭然后再次打开”对我有用。

pip uninstall ipython
pip install ipython

The classic 'have you tried turning it off and on again' worked for me.

pip uninstall ipython
pip install ipython
与往事干杯 2024-09-04 13:17:18

这绝对应该有效,因为它在我的情况下有效

conda install ipython  
pip install jedi==0.17.2

This should definitely work as it worked in my case

conda install ipython  
pip install jedi==0.17.2
当梦初醒 2024-09-04 13:17:18

截至目前,在 OSX 上,pip 安装的 ipython 不提供制表符补全,pyreadline release.py 已损坏.. 什么 WFM:

easy_install ipython readline

YMMV。

As of right now, on a OSX, pip installed ipython doesn't give tab completion, pyreadline release.py is busted .. what WFM:

easy_install ipython readline

YMMV.

我很坚强 2024-09-04 13:17:18

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:

  1. 安装“官方”readline:easy_install readline
  2. 发现它在哪里。查看 /Library/Python/site-packages/readline-*.egg 或在 Virtualenv 对应项中
  3. 发现 ipython bin 的位置: which ipython
  4. 将一行添加到此文件,在 import sys 行之后添加 readline Egg 路径。

我的 virtualenved ipython bin 脚本工作如下:

#!/Users/alanjds/src/git/cervejeiras/venv/cervejeiras-lfs/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ipython==0.13.1','console_scripts','ipython'
__requires__ = 'ipython==0.13.1'
import sys

### ONLY LINE ADDED:
sys.path.insert(0, '/Users/alanjds/src/git/cervejeiras/venv/cervejeiras-lfs/lib/python2.6/site-packages/readline-6.2.4.1-py2.6-macosx-10.6-fat.egg')
####

from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('ipython==0.13.1', 'console_scripts', 'ipython')()
    )

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:

  1. Install the "official" readline: easy_install readline
  2. Discover where it is. Look at /Library/Python/site-packages/readline-*.egg or in your Virtualenv counterpart
  3. Discover where ipython bin is: which ipython
  4. Add ONE LINE to this file, adding the readline egg path right after import sys line.

My virtualenved ipython bin script got working as follow:

#!/Users/alanjds/src/git/cervejeiras/venv/cervejeiras-lfs/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ipython==0.13.1','console_scripts','ipython'
__requires__ = 'ipython==0.13.1'
import sys

### ONLY LINE ADDED:
sys.path.insert(0, '/Users/alanjds/src/git/cervejeiras/venv/cervejeiras-lfs/lib/python2.6/site-packages/readline-6.2.4.1-py2.6-macosx-10.6-fat.egg')
####

from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('ipython==0.13.1', 'console_scripts', 'ipython')()
    )
初心 2024-09-04 13:17:18

我意识到这是一个非常老的问题,但是上面的答案都不适合我(这是当你用谷歌搜索这种性质的问题时得到的第一个结果)。

我应该提到这并不是 Windows 所独有的,我在运行 CentOS 6.5 和 Python 2.7 时遇到了问题,

这就是我所做的:

apt-get/yum install ncurses-devel
#If you want history in iPython:
apt-get/yum install sqlite-devel
easy_install ipython readline
ipython

In [1]: from 
Display all 391 possibilities? (y or n)

如果您没有 -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:

apt-get/yum install ncurses-devel
#If you want history in iPython:
apt-get/yum install sqlite-devel
easy_install ipython readline
ipython

In [1]: from 
Display all 391 possibilities? (y or n)

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!

遇见了你 2024-09-04 13:17:18

我遇到了这个问题,并且知道我已经为我正在寻找的模块安装了 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.

单调的奢华 2024-09-04 13:17:18

在我的例子中,我必须 mv ~/.ipython{,.bak}

I had to mv ~/.ipython{,.bak} in my case.

浅沫记忆 2024-09-04 13:17:18

如果您使用 Jupyter 笔记本,并且在尝试了此处帖子中建议的所有步骤后仍然可以使用 Tab 自动完成功能,则您可能需要检查是否尝试在函数定义中使用 Tab 自动完成功能。如果您的导入语句是如下函数的一部分,您将无法获得 Tab 自动完成功能。您需要将导入语句放在函数外部,并在要求包自动完成之前执行一次。

def myfunction():
    import pandas as pd
    import numpy as np

    a = pd.DataFrame(np.random.normal(1,3, (4,4))
    return a

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.

def myfunction():
    import pandas as pd
    import numpy as np

    a = pd.DataFrame(np.random.normal(1,3, (4,4))
    return a
风渺 2024-09-04 13:17:18

我在使用 numpy 库时遇到了同样的问题。该问题与 ipython 或 jupyter 笔记本的特定版本有关,只需更新 ipython 或 jupyter 即可解决。
如果您使用的是 anaconda 或 miniconda 这样的 conda 环境,则使用 anaconda 来更新该环境中的 ipython

conda update ipython

如果使用 anaconda,您还需要更新 q​​tconsole 有时

conda update qtconsole

anaconda 限制 ipython 的更新,然后尝试

conda update -all

如果您不使用环境,则直接使用 更新点

pip update 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

conda update ipython

In case of anaconda you also need to update the qtconsole

conda update qtconsole

Sometimes anaconda constraints the update of ipython then try

conda update -all

If you are not using a environment then directly update using pip

pip update ipython
花辞树 2024-09-04 13:17:18

我通过安装 jedi-language-server 解决了我的问题:

pip install -U jedi-language-server

PS,我在虚拟环境中从 Conda 安装了 Ipython,并在激活环境时使用了上述命令。

I solved my issue by installing jedi-language-server:

pip install -U jedi-language-server

PS, I was installed Ipython from Conda in a virtual env and used the above command when the env was activated.

一场春暖 2024-09-04 13:17:18

要检查 ipython 及其使用的模块是否匹配,请运行 pip check ipython
对于我在 2021 年 7 月使用 ipython 7.25 进行的配置,这给出了一个很好的明确警告:

ipykernel 6.0.1 要求 importlib-metadata<4; python_版本 < “3.8.0”,但您有 importlib-metadata 4.6.0。

您当然可能会看到不同的警告——
这只是一个示例,与制表符补全无关。

然后降级它,例如
pip install 'importlib-metadata<4' # 不要忘记“引号”

成功卸载 importlib-metadata-4.6.0
成功安装importlib-metadata-3.10.1


Also useful:

  • pip list -- $PYTHONPATH 中的所有内容,以及版本和位置
  • pip check -- 所有内容
  • pip show ipython --

需要:traitlet、pygments、jedi、decorator、pickleshare、pexpect、appnope、matplotlib-inline、setuptools、prompt-toolkit、backcall

但要查看所需的版本,您必须查看
.../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:

ipykernel 6.0.1 has requirement importlib-metadata<4; python_version < "3.8.0", but you have importlib-metadata 4.6.0.

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'

Successfully uninstalled importlib-metadata-4.6.0
Successfully installed importlib-metadata-3.10.1


Also useful:

  • pip list -- everything in your $PYTHONPATH, with version and location
  • pip check -- everything
  • pip show ipython --

Requires: traitlets, pygments, jedi, decorator, pickleshare, pexpect, appnope, matplotlib-inline, setuptools, prompt-toolkit, backcall

but to see the required versions you have to look at
.../site-packages/ipython-*.dist-info/METADATA

鲸落 2024-09-04 13:17:18

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 commandpython setup.py install This will intall pyreadline in C:\Python27\Lib\site-packages

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