Using IDEs

There are several popular IDEs that are commonly used for interactive work with Python. Here we will show how to load Jupyter, VS Code, and Spyder.

Jupyter

JupyterLab 🚀

JupyterLab is the next-generation web-based user interface for Project Jupyter. It provides an interactive development environment for working with notebooks, code, and data. JupyterLab offers a more flexible and powerful interface compared to the classic Jupyter Notebook, allowing users to arrange multiple documents and activities side by side in tabs or split screens.

Jupyter Notebook 📝

Jupyter Notebook is a sibling to other notebook authoring applications under the Project Jupyter umbrella, like JupyterLab. Jupyter Notebook offers a lightweight, simplified experience compared to JupyterLab.

  • Running python requires a kernel to be started. IPython is the default kernel for Jupyter if you want to run python code. You can also install other kernels to run other programming languages.

  • A Jupyter Notebook is made up of cells. There are two main types of cells: Code cells and Markdown cells.

  • Code cells 🧩 allow you to write and execute Python code. When you run a code cell, the output is displayed directly below the cell.

  • Markdown cells 📝 allow you to write formatted text using Markdown syntax. This is useful for adding explanations, headings, lists, links, and even LaTeX equations to your notebook.

  • You can run a cell by selecting it and pressing Shift + Enter or by clicking the “Run” button in the toolbar ▶️.

  • Cell execution order matters - Jupyter allows cells to be run in any order, but the execution number in square brackets shows the order in which cells were actually run.

  • Restarting the kernel 🔄 is useful when you want to clear all variables and start fresh. Go to “Kernel” > “Restart”.

  • Clearing all outputs 🧹 can be done by selecting “Cell” > “All Output” > “Clear” from the menu.

  • Exporting notebooks 📤 to different formats (HTML, PDF, Markdown, etc.) can be done via “File” > “Download as” or “Export Notebook As”.

  • Using magic commands ✨ like %timeit, %matplotlib inline, %load, and %%writefile can enhance your workflow significantly.

Exercise

  • Try Jupyter interface with the following Notebook Code.

  • Either start an interactive session with 4-8 cores and 1-2 hr walltime or stay on the login node.

  • cd into your project directory and start Jupyter Notebook or JupyterLab as described in previous sections. (Optional: load matplotlib module by searching it with module spider matplotlib and then loading it.)

  • Create a new Python 3 notebook.

Spyder

Features

When you open Spyder you will see a three-pane layout similar to other scientific IDEs: a large Editor on the left, and one or more utility panes on the right and bottom. The exact arrangement can be customised and saved as a layout.

Main panes and useful tabs

  • Editor (left) 📝
    • Edit multiple files in tabs : use the Run toolbar (green ▶️) to run the current file or selection.

    • You can mark cells with # %% (or # %%% for multi level cells) and run cells interactively.

    • Use the burger menu on the editor pane to split, undock or save layout.

  • Utility pane (Top-right) 🧰
    • Help 🔍: documentation and contextual help for the symbol under the cursor.

    • Variable explorer 🧾 : table view of in-memory variables with types and values; inspect, edit or remove variables.

    • Files 📂 : file browser for the current working directory.

    • Plots 📈 : interactive plots panel (may be a tab in recent versions); can be undocked to a separate window for better interaction.

  • Console and History (Bottom-right) 🖥️
    • IPython console(s) : interactive Python connected to the currently selected kernel/environment.

    • History log : previously executed commands from the console.

Exercise

  • Try Spyder interface with the following code.

  • Either start an interactive session with 4-8 cores and 1-2 hr walltime or stay on the login node.

  • cd into your project directory.

  • Start Spyder from your python env that you created in previous session.

  • Type out (or copy) the following code into the IDE editor and run it to see the results.

VS Code

Features

VS Code provides a flexible, extensible interface that is well suited for editing, debugging, and remote development. Below are the main panes, useful workflows, and configuration tips to get the most out of VS Code when working locally or connected to an HPC resource.

Main panes and useful panels

  • Explorer (left) 📁
    • File tree and quick file operations.

    • Right-click to open terminals, reveal in OS file manager, or run commands.

  • Editor (center) ✍️
    • Supports tabs, split editors, and editor groups.

    • Rich file-type support (syntax, linting, formatting).

    • Notebook editor for .ipynb files when Jupyter extension is installed.

  • Side bar (left) 🔧
    • Run & Debug, Source Control, Extensions, Search, Remote Explorer.

  • Panel (bottom) 🖥️
    • Integrated Terminal(s): run jobs, activate envs, and submit sbatch scripts.

    • Output, Problems, Debug Console, and Tests.

  • Status bar (bottom) ℹ️
    • Shows current interpreter, Git branch, line endings, and active extensions.

    • Click the interpreter area to switch Python interpreters or kernels.

Exercises

Exercise

  • Try running a Scipy and a Pytorch example in your favorite IDE.

  • Create a Virtual env using your faviroute package manager and install the packages.

  • For an extra challenge: Run the same code in .ipynb format in your IDE. This requires you to install jupyter notebook in your virtual environment.

Learning outcomes:
  • How to use IDE on any system

  • How to run code on IDE

  • How to install and manage extensions on remote VSCode server