Visual Studio Code for Ubuntu

https://gogs.elic.ucl.ac.be/pbarriat/learning-vscode

Pierre-Yves Barriat
ACELI Training Sessions March 26th, 2024

What is Visual Studio Code ❓

Visual Studio Code (VS Code) is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux.

It has a rich ecosystem of extensions for languages (such as C++, Fortran, Java, Python, etc) and runtimes (Git, Jupyter, etc)

VSC is one of the most popular and powerful text editors used by software engineers today

free, open-source and available for macOS, Windows and Linux 👍

26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

VS Code

You can install Visual Studio Code from the web link here

wget the deb package then dpkg -i code*.deb

That's it ! 😃

26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

Install extensions

  • Python
  • Jupyter

26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

Jupyter Notebook in VS Code

Create a new Juyter Notebook

Fill the first cell

import numpy as np
26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

Try to run the cell

you must choose a Python environment first (Python 3.6)

If 💥 ... maybe you must install a missing extension !

So open a terminal in VS Code an do

sudo apt install python3-pip
26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

Now, install the missing Python extension ...

pip instal numpy

... and run the cell again: great, it's OK now 😃

26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

Let's try a full notebook example

Install Git : sudo apt install git -y

Now clone this Git repository

git clone https://forge.uclouvain.be/barriat/learning-vscode.git

You don't already know what's Git ❓
Shame on you ! 😖

It's not to late: take a look here
https://gogs.elic.ucl.ac.be/TECLIM/Git_Training

Now open the file example.ipynb

26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

The first cell implies you must install some requirements

To run this example, install the extensions below

pip install netCDF4
sudo apt install libgeos-dev libgdal-dev
pip install cartopy

Now, try to run all the cells of this notebook ❗

26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

VS Code nice extensions

  • Tabnine : code faster with AI code completions
  • Regex Previewer : shows the current regular expression's matches
  • Modern Fortran : Fortran syntax is missing in built-in version
26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat

Visual Studio Code for Ubuntu 💬

26/03/2024 | Visual Studio Code for Ubuntu | PY Barriat