Skip to content

Using Jupyter Notebooks on MeluXina through VS Code

Jupyter Notebooks are interactive documents that combine code, text (Markdown), visualizations, and outputs in one place. They are especially useful for data science, machine learning, and sharing results, as they let you combine code execution with explanations and outputs in real time. Using them in VS Code adds powerful features like integrated version control, better code navigation, extensions, and the ability to work with multiple languages or larger projects in a more structured development environment.

1. Setup

Connect to MeluXina and load the Python module using module load Python, and then connect to your preferred python environment.

2. Running the Jupyter server

Once in the python environment, run the following line to start a Jupyter server instance:

jupyter notebook --no-browser --port=8888 --ip=0.0.0.0

If everything went fine, you should see the following message on the console:

Console message

This means that the Jupyter server is running successfully on those URLs, which we are going to need later. The current terminal will now be dedicated only to running the Jupyter server.

3. VS Code setup

Once the Jupyter server is running, open VS Code and connect to MeluXina via SSH.

Meluxina SSH

Once connected, you can browse your files stored in MeluXina using the VS Code file explorer and either open an already existing jupyter notebook .ipynb file, or create a new one.

VSCode files

4. Connecting to the running Jupyter server through VS Code

Open the notebook file and click on “Select Kernel” on the top right corner of the window.

Select kernel

A window will open on the top of the window asking to select a kernel source. Click on the “Existing Jupyter Server…” option.

Existing Jupyter Server

Copy one of the URLs where the server is running (see step 2), and paste it on the search bar. Then, press “Enter” on your keyboard.

Enter URL

A prompt will show asking to change the server display name, just press “Enter” to use the default name.

Display Name

Finally, it will ask you to select the kernel for the server. Use the one you have available, in this case Python 3 (ipykernel).

Select Kernel

Once you have selected the kernel, everything is ready to go. Run any cell from your notebook to start the kernel. Any library installed in your python environment will be available to use, and any library installed from the notebook using !pip install… will be installed in the python environment where the server is running.