Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import tab-complete fail with ipython 2.0 shell #5514

Closed
GhislainHivon opened this issue Apr 3, 2014 · 9 comments · Fixed by #5582
Closed

import tab-complete fail with ipython 2.0 shell #5514

GhislainHivon opened this issue Apr 3, 2014 · 9 comments · Fixed by #5582
Milestone

Comments

@GhislainHivon
Copy link

In the shell, when trying to tab-complete a module name for import, the propose completion is not modules names.

with ipython 2.0

>>> import co<tab>
coerce(     compile(    complex(    continue    copyright(

That the same list as when tab-complete without anything

instead of what ipython 1.1 give

>>> import co<tab>
code                codeop              commands            configparser        contextlib          copy_reg
code_erreur         collections         compileall          constantes          cookielib           copyreg
codecs              colorsys            compiler            constantes_vivaldi  copy                coverage

I'm on fedora 17, with python 2.7 in a virtualenv

@drkjam
Copy link

drkjam commented Apr 7, 2014

I am also seeing this. I'm using OSX and Python 2.7 provided by brew. Works fine with IPython 1.2.1 and earlier.

@pmakowski
Copy link

A user reported the same bug under Mageia with Python2.7 and Python3.3

@takluyver
Copy link
Member

So far I'm unable to replicate this (Debian, Python 3.3 and 2.7), and unsure what could be causing it - I don't think that code has had any major changes since 1.x.

@minrk
Copy link
Member

minrk commented Apr 9, 2014

@GhislainHivon @drkjam do you have PYTHONSTARTUP set?

@mario-grgic
Copy link

Ok, some more info here. I have PYTHONSTARTUP variable defined.

echo $PYTHONSTARTUP
/Users/mariogrgic/.pythonrc
$
$ cat .pythonrc
import rlcompleter
import readline

readline.parse_and_bind("tab: complete")
del rlcompleter
del readline

If I now unset PYTHONSTARTUP

$ unset PYTHONSTARTUP

and launch IPython, import completions now work. So it does have something to do with PYTHONSTARTUP variable or what the startup script is doing.

@takluyver
Copy link
Member

IPython now runs PYTHONSTARTUP, and is less aggressive about using its own completer. So when you configure a more basic completer in PYTHONSTARTUP, IPython ends up using that instead of its own completer.

@mario-grgic
Copy link

Ok, that explains it. I'm not sure if this is not working for the same reason for other people experiencing this problem.

@GhislainHivon
Copy link
Author

Same thing, PYTHONSTARTUP with readline.parse_and_bind("tab: complete") in it.

I found a easy way to test if in ipython
http://stackoverflow.com/a/17826459/611741

try:
     cfg = get_ipython().config
     # in pyton
 except :
     pass 

@takluyver
Copy link
Member

The name get_ipython should exist if it's run from IPython.

@minrk minrk added this to the 2.1 milestone Apr 10, 2014
minrk added a commit that referenced this issue Apr 16, 2014
should avoid conflicts between IPython and Python completion setup

Many folks have completion setup in PYTHONSTARTUP for the plain Python REPL. In IPython 1.x, this wasn't an issue because IPython reset the readline state after every execution. This was removed in 2.0 (#4353), allowing users to customize readline behavior. One effect of this is allowing PYTHONSTARTUP to customize *IPython's* readline behavior, which seems to be something nobody wants.

This PR simply re-applies the old reset readline behavior after running PYTHONSTARTUP.

closes #5514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants