· python ipython poetry til

iPython: How to disable autocomplete

I’ve been toying with the idea of using iPython as the Python REPL for videos on @LearnDataWithMark, but I wanted to disable the autocomplete functionality as I find it too distracting. In this blog post, I’ll show how to do it.

First, let’s install iPython:

poetry add ipython

And now we’ll launch the iPython REPL:

poetry run ipython
Python 3.11.4 (main, Jun 20 2023, 17:23:00) [Clang 14.0.3 (clang-1403.]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.16.1 -- An enhanced Interactive Python. Type '?' for help.

Now, let’s say I type `x = ` to populate a variable. It will suggest something like the following:

ipython autocomplete
Figure 1. Not so helpful autocomplete

I’ve only just started the session so this isn’t particularly useful. I’m not sure where it’s getting the suggestions from - perhaps from my previous normal Python REPL?

In any case, I want to turn them off, which we can do from the iPython configuration file. You can create one of those by running the following command:

poetry run ipython profile create
[ProfileCreate] Generating default config file: PosixPath('/Users/markhneedham/.ipython/profile_default/ipython_config.py')

If we open that file, the first few lines will read like this:

# Configuration file for ipython.

c = get_config()  #noqa

To disable autocomplete, let’s add the following line:

c.TerminalInteractiveShell.autosuggestions_provider = None

If we then close the iPython REPL and launch it again, we can try the `x = ` code fragment again:

ipython autocomplete off
Figure 2. No autocomplete

Job done!

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket