---
title: "Jupyter on VSCode"
canonical: "https://kb.uconn.edu/space/SH/26640089153/Jupyter%20on%20VSCode"
format: markdown
---
Accessing Jupyter Notebooks is fairly straight forward on VSCode. Through the tunneling used by our [base VSCode guide](https://uconn.atlassian.net/wiki/spaces/SH/pages/26626326576), you are able to start an interactive session requesting for the resources needed and use it in your notebook for heavily computational analysis.


### 📘 Here’s an example:

1. We can start by creating a custom [conda environment](https://uconn.atlassian.net/wiki/spaces/SH/pages/26079723879) that has the packages that you need:

```
(base) [anl14042@login4 ~]$ conda create --name vscode_notebook python=3.9
```

2. Then start an interactive session and tunnel to connect to VSCode:

```
(base) [anl14042@login4 ~]$ srun --ntasks=12 --nodes=1 --partition=general --time=6:00:00 --exclusive --pty bash
srun: job 5407517 queued and waiting for resources
srun: job 5407517 has been allocated resources

```

3. Load VSCode and start the tunnel:

```
(base) [anl14042@cn471 ~]$ module purge
(base) [anl14042@cn471 ~]$ module load vscode/
Loading vscode/2024
  Loading requirement: slurm/slurm/22.05.9 pre-module post-module
(base) [anl14042@cn471 ~]$ tunnel
*
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
✔ How would you like to log in to Visual Studio Code? · Microsoft Account
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ******** to authenticate.

```

4. Once you’re signed in, either begin using the browser version or go back to your desktop VSCode.

We’ll create a directory and work within it:

```
(base) [anl14042@cn471 ~]$ mkdir jupyter_vscode
(base) [anl14042@cn471 ~]$ cd jupyter_vscode/
```

5. Connect to your tunnel in VSCode:

![image-20240123-174409.png](media://24aa84a6-4e2f-4423-8c52-d723435596b2)

6. Sign in, navigate to your directory of choice. Then create a jupyter notebook (File, New File):

![image-20240123-174656.png](media://dd0b1436-3dcc-4c11-b98e-0415bd6bd929)

7. Now click “Select Kernel” and then “Python Environments” to find your custom conda environments!

![image-20240123-175056.png](media://8b4ab337-ae7d-4d65-a439-6d2ab111ce04)

> ℹ️ If the environments do not show up, the Jupyter Extension needs to be installed from within VSCode.  Once the extension is installed, the environments should show up.

8. Select the environment we created earlier “vscode_notebook” with python 3.9.

Let’s test it! Click the “play” or run button to run the cell.

![image-20240123-175403.png](media://6e58c7c6-1cb5-4bcc-a15f-1da6f0e06f16)

9. You may be asked to install some things, click yes and install all.

![image-20240123-175504.png](media://3dd1e93a-1909-4edb-b5f4-b80e0d96b263)

10. Remember to exit your VSCode using “ctrl+c” and to end your interactive session when you’re done!