Updated: Mar 29, 2026
| 4 min

The Lab Setup: Preparing Your Local and Cloud Python Environment

Master your Data Science workflow. A step-by-step tutorial on setting up VS Code, Python virtual environments (venv), and Google Colab for professional analysis.

Banner for "Data Science with Python" showing a snake and data analysis tools

Before we dive into data science with Python, we need a solid place to write and run our code.

In this chapter, we’ll set up:

  • A local environment on your computer
  • A cloud environment using Google Colaboratory

Both approaches are valuable, and you’ll likely switch between them depending on your project.

Local Environment

We’ll start by preparing our local machine for Python development. If you haven’t already, make sure to download and install the latest version of Python from the official site: https://www.python.org/downloads/

Make sure to check the option “Add Python to PATH” during installation if you’re on Windows. To verify Python is installed correctly, open a terminal on your computer and type the following command:

python --version

You should see a version number like Python 3.x.x

Install Visual Studio Code

A powerful and lightweight editor, VS Code is one of the most popular tools for Python and data science.

  1. Download it from the official website: https://code.visualstudio.com/
  2. Open VS Code and navigate to the Extensions panel (the icon with four squares).
  3. Install the Python extension (search for: ms-python.python)
  4. Install the Jupyter extension (search for: ms-toolsai.jupyter)

Create a Project Folder

Before creating a virtual environment, start by setting up a project folder:

  1. Create a new folder anywhere on your system (e.g., my-first-ds-project).
  2. In VS Code, go to File → Open Folder and select the folder.
  3. Open a terminal inside VS Code with Ctrl + J (or View → Terminal).

Virtual Environments (venv)

A virtual environment isolates your project’s Python packages so they don’t interfere with other projects.

In the VS Code terminal, create a virtual environment:

python -m venv venv

Activate it:

  • Windows:
    venv\Scripts\activate
  • Mac/Linux:
    source venv/bin/activate

Once activated, you should see (venv) at the beginning of your terminal line. This confirms you are successfully operating within your isolated project environment.

To deactivate the venv is for both Windows and Mac/Linux the same, type the following in your terminal:

deactivate

Installing Packages

With our virtual environment active, we can install the core libraries for our data science project with Python’s package manager (pip):

pip install numpy pandas matplotlib seaborn scikit-learn scipy
  • numpy: For fast numerical computations (especially arrays).
  • pandas: For efficient data handling and analysis (DataFrames).
  • matplotlib: For creating static, interactive, and animated visualisations.
  • seaborn: For high-level, aesthetically pleasing, and informative statistical data visualisations built on top of Matplotlib.
  • scikit-learn: The most popular library for machine learning algorithms.
  • scipy: For scientific and technical computing, including optimisation, statistics, linear algebra, and signal processing.

These libraries form the core of most data science projects.

Creating a Notebook in VS Code

VS Code makes working with notebooks extremely convenient once the Python and Jupyter extensions are installed.

You can create a new Jupyter notebook in two ways:

  • Method 1: Using the Command Palette
    1. Press Ctrl + Shift + P to open the Command Palette.
    2. Type “Jupyter: Create New Jupyter Notebook”.
    3. Press Enter, a new .ipynb file opens, ready for code.
  • Method 2: Creating a File Manually
    1. In the Explorer sidebar, click the New File icon.
    2. Name the file with a .ipynb extension, e.g.: analysis.ipynb

VS Code will automatically open it in notebook mode. Once the notebook opens, you can:

  • Add cells by clicking + Code or + Markdown
  • Run Python code directly in your project’s virtual environment
  • View charts and visualisations inline

Notebooks are ideal for experimentation, visualisation, and documenting your thought process.

Linking Our Notebook with the Virtual Environment

Now that you have created your Jupyter notebook (.ipynb file) and installed all the necessary packages within the venv, the final step is to tell VS Code to use that environment as the notebook’s Kernel.

If you skip this step, the notebook will use your computer’s default Python installation, which will likely result in a ModuleNotFoundError when you try to import your installed libraries.

How to Select the Kernel in VS Code:

  1. Open your Notebook: Ensure your .ipynb file is open in the VS Code editor.

  2. Locate the Kernel Selector: Look for the current kernel name in the top-right corner of the notebook window. It might currently say something like “Python 3” or “No Kernel Selected.”

  3. Select Your Environment: Click on the current kernel name. A list of available Python environments will appear.

  4. Choose Your venv: Select the option that corresponds to the virtual environment you just created. It will typically be named something like:

    Python 3.x.x (venv) (The name of your project folder)

Once selected, the name in the top-right corner should change to show your (venv). You are now ready to run code in your notebook, knowing it is correctly isolated and has access to all the libraries you installed.

Google Drive (Colaboratory)

If you prefer a cloud-based setup or want to avoid installing anything locally, Google Colab is an excellent option. It provides:

  • A fully configured Python environment
  • Free GPU access
  • Automatic saving to your Google Drive
  • Easy sharing and collaboration

Enable Colab in Google Drive

  1. Go to Google Drive.
  2. Right-click → MoreConnect more apps.
  3. Search for “Colaboratory”.
  4. Click Install.

You can now create notebooks anytime via: Right-click → More → Colaboratory

Colab notebooks run entirely in the cloud, and many common data science libraries are installed by default.

Series: Data Science with Python

3 Chapters