Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ambiguous tab completion not working in iPython on Windows

I am running IPython on Windows 7 x64 with pyreadline installed. If I start a new session and type:

import numpy
nu<TAB>

Then nu autocompletes to numpy. However, if I start a new session and try this:

import numpy
n<TAB>

Then nothing happens. I would expect it to cycle through all of the possible completions. I'm currently using out of the box config, do I need to change a setting to enable ambiguous tab completion or am I just out of luck?

EDIT: To address the comment from ma3204, here is another example (start with fresh ipython session):

[In 1]: value1 = 5

[In 2]: value2 = 6

[In 3]: va<TAB>       ... nothing happens
[In 3]: va<Ctrl + l>
vars   value2 value1

[In 3]: val<TAB>      ... completes to 'value'
[In 3]: value
[In 3]: value<Ctrl + l>
value2 value1

[In 3]: value

When I type va<TAB> above I would expect each tab press to cycle through value1, value2, vars, value1, value2, etc.

like image 837
mwolfe02 Avatar asked Sep 22 '10 17:09

mwolfe02


People also ask

Does IPython have tab completion feature?

IPython and compatible frontends not only can complete your code, but can help you to input a wide range of characters. In particular we allow you to insert a unicode character using the tab completion mechanism.

How do I enable tab completion in Jupyter notebook?

Enable autocomplete feature To enable code autocomplete in Jupyter Notebook or JupyterLab, you just need to hit the Tab key while writing code. Jupyter will suggest a few completion options.

How do I get suggestions on IPython?

Simply hit the “Tab” key while writing code. This will open a menu with suggestions. Hit “Enter” to choose the suggestion.

What is shell tab completion?

One extremely time-saving feature built into the Bash Shell is the ability to "tab-complete" commands. Simply hit the tab key while you are typing a command, and the shell will automatically finish the command for you. Or, if it is ambiguous, it will provide options (you might have to type tab again).


2 Answers

You have to copy config file for pyreadline to your HOME folder (C:\Users\< username >).

Open Command line and execute that:

copy "C:\Program Files (x86)\Python26\Lib\site-packages\pyreadline\configuration\pyreadlineconfig.ini" %HOMEPATH%
like image 113
Luka Zakrajšek Avatar answered Nov 02 '22 14:11

Luka Zakrajšek


Just installed python 2.6 and numpy, ipython and so on. I am also annoyed of this. On my other computers with older installations it works. I use the completions list very much to see what commands are available so I feel frustrated when it doesn't work.

EDIT: Found that you can get it with CTRL-l. Looked in ipythonrc and it should work like I am used to but not. The CTRL-l work though. Will see if it kicks back on. Seem to remember that I had similar trouble before but it worked after some time.

like image 6
Slasher Avatar answered Nov 02 '22 16:11

Slasher