Dr Seán Carroll

by Dr Seán Carroll

Lesson

Coding Environment Setup

7. Downloading Python and Visual Studio Code

Now it’s time to start setting up your development environment. If you’ve already set up a coding environment to work with Jupyter Notebooks, I suggest you stick with that. This lesson is really for anyone who is starting from scratch.

The most fundamental thing we need to get is a Python distribution - this will give us the ability to execute Python code on our computer. The simplest way to get most of the stuff we need in one step is to download the Anaconda Python distribution.

The Anaconda Python Distribution


Anaconda is a popular open-source distribution of Python commonly used for scientific computing and data science. As we start to go beyond the very basics in Python, you’ll see that we make use of many third-party packages when we write Python code. These are libraries of code that are written and maintained by other organisations or groups. This is hugely beneficial as we can build on what others have already done.

Not only will Anaconda provide us with a core Python distribution, but our download will include a suite of pre-installed packages tailored for scientific computing, data science, and machine learning applications.

It also includes tools like JupyterLab which is the popular integrated development environment I mentioned previously. Anaconda also features conda, a powerful package and environment manager, which simplifies the process of installing and managing libraries. We’ll talk more about this later.

In this lesson, we’ll download and install the Anaconda distribution and take a quick look around. I’ll be using macOS, but honestly, all we’re really doing is downloading software from the internet - so the process on Windows or Linux will be very similar. If you’ve downloaded software before, you’ll be fine. Just make sure to download the relevant version for your operating system. If you run into any problems, jump into the forum thread for this lesson.

Downloading and installing the Anaconda Distribution

Let’s start by navigating to the Anaconda download page. Depending on when you visit this page, it may look different but just hunt around for the download button.

The Anaconda Distribution Download page (at time of writing) | academy.digilab.co.uk

Figure 1. The Anaconda Distribution download page (at time of writing).

Once you download the installer package, navigate to wherever you downloaded it to, usually your downloads folder, and double-click it to start the installation process. Then simply follow the installation wizard - all of the default options are fine.

The Anaconda Navigator

Once the installation is complete, we should have access to almost everything we need. Now, we have two ways to interact with all our new tools. One is directly through the command line in a terminal window, and the other is through a graphical user interface called Anaconda Navigator.

Moving forward, we’ll be using the command line tools in a terminal window, because it’s generally a lot quicker. But let’s first take a brief look at the Anaconda Navigator in case you want to explore it further.

Search for a programme on your computer called Anaconda Navigator and launch it. You can think of this as a command centre where you can manage everything Python-related on your machine through a user interface, as opposed to a terminal.

The Anaconda Navigator | academy.digilab.co.uk

Figure 2. The Anaconda Navigator.

In the home tab, you’ll notice a range of different programmes we can launch, the two of interest to us are JupyterLab and Visual Studio Code. These are probably our best two options for working with Jupyter Notebooks locally on our machines. We’ll dig deeper into Visual Studio Code soon. For now, launch JupyterLab.

You’ll notice a web browser open - JupyterLab uses your web browser as a user interface, but no connection to the internet is required. This is a fully featured development environment for Jupyter Notebooks.

We have a standard file explorer on the left and our main work window to the right. We create a new Jupyter Notebook by clicking on the Python 3 (ipykernel) launcher. This will generate a fresh Notebook that we can start coding in. We can see the new notebook, Untitled.ipynb in the file explorer (ipynb is the file extension for Jupyter Notebooks). We won’t spend any more time in here as we’ll be using Visual Studio code but at least now you know how to launch a Jupyter Notebook inside JupyterLab, if you want to poke around yourself.

The JupyterLab development environment | academy.digilab.co.uk

Figure 3. The JupyterLab development environment.

The Terminal and Command Line


Before downloading Visual Studio Code, let’s take a quick look at the terminal. Search for the terminal on your computer and open a fresh window. From here, we can access anything on our computer and execute any valid command we like.

For example, if we want to open up JupyterLab, directly into the file we left previously without going through Anaconda Navigator, we can simply type the command Jupyter Lab and press enter, and this will launch the programme directly.

We can confirm the version of Python that was installed with the Anaconda Distribution by typing python -V. Similarly, we can check our version of the package manager, conda, by typing conda -V.

We can also type conda list to see all of the third-party packages being managed by our package manager. We’ll return to the terminal and conda in the next lesson. Next, let’s get Visual Studio Code installed.

Installing Visual Studio Code


Visual Studio Code, often referred to as VS Code, is a versatile and powerful development environment developed by Microsoft. It’s available on Windows, macOS and Linux. It has a rich set of features, a thriving community and a massive library of extensions that extend its functionality. It’s probably the most popular development environment in use today.

It also benefits from new AI features, like Copilot, thanks to Microsoft’s collaboration with OpenAI. Note that although VS Code is completely free to use, Copilot is a paid feature. It’s by no means essential, but be careful - once you get used to it, you won’t want to code without it! Copilot has probably become the biggest differentiator between VS Code and any other development environment.

To download VS Code, navigate to the download page and select your installer of choice. Again, just like the Anaconda Distribution, simply follow the instructions to install the programme. Once installation is complete, confirm everything has worked by searching for and launching VS Code.

Visual Studio Code interface | academy.digilab.co.uk

Figure 4. Visual Studio Code interface.

We’ll pause here. Before exploring VS Code in more detail, we’ll briefly talk about conda and environment management in the next lesson.