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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay