DEV Community

Pavol Z. Kutaj
Pavol Z. Kutaj

Posted on

How to use iPython in VS Code

The aim of this page πŸ“ is to explain how to use IPython as the default Python REPL (watch Sebastian Witowski's talk if not convinced) and configure VS Code to execute code in IPython, as I am slowly switching to iPython for my default REPL. A big part of this is to be able to execute selections of code with shift+enter in VS Code, and then quickly toggle between ipython for exploration, and vscode for code editting. I was toying with an idea to create a pure-vim workflow, but the combination of VS Code + iPython set up this fast is too tempting.

  • Configure VS Code to use IPython with Shift+Enter: Open settings (Ctrl+, or Cmd+,), and add/update in settings.json:
python.terminal.launchArgs": [
    "-m",
    "IPython",
    "--no-autoindent",
],
Enter fullscreen mode Exit fullscreen mode
  • Example issue when running IPython:
  /opt/homebrew/opt/python@3.13/bin/python3.13: No module named ipython
Enter fullscreen mode Exit fullscreen mode
  • Resolve by installing IPython in correct environment:
  python -m pip install ipython
Enter fullscreen mode Exit fullscreen mode
  • I am using shift+alt+p for quick toggling between iPython in a terminal panel and VS Code proper. This is the keyboard shortcut config
    {
        "key": "shift+alt+p",
        "command": "workbench.action.focusPanel",
        "when": "!panelFocus"
    },
    {
        "key": "shift+alt+p",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "panelFocus"
    }
Enter fullscreen mode Exit fullscreen mode

LINKS

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free β†’

πŸ‘‹ Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay