License: CC-BY-NC-SA 4.0
Author: Murilo M. Marinho (murilo
Prerequisites for the learner¶
This lesson has no prerequisites. It is designed to be the first lesson in the course.
I found an issue¶
Thank you! Please report it at https://
Introduction¶
Before starting with the lessons, you need to set up a suitable Python environment. This lesson guides you through creating a Python virtual environment and installing all the dependencies required for this project.
A virtual environment is an isolated Python environment that allows you to install packages without affecting your system-wide Python installation. This ensures reproducibility and avoids dependency conflicts.
Creating a virtual environment¶
The recommended approach is to use Python’s built-in venv module. Open a terminal and run:
python3 -m venv venvThis creates a directory called venv in your current working directory containing the virtual environment.
Activating the virtual environment¶
Before installing packages or running the notebooks, activate the virtual environment:
Linux / macOS¶
source venv/bin/activateWindows (Command Prompt)¶
venv\Scripts\activate.batWindows (PowerShell)¶
venv\Scripts\Activate.ps1Once activated, your shell prompt should display (venv) to indicate the virtual environment is active.
Installing the required packages¶
All lessons in this project use the following core dependencies:
numpy: Numerical computing library for arrays, matrices, and linear algebra operations.
matplotlib: Plotting library used in later lessons for visualisation.
Run the following command to install them:
pip install numpy matplotlibVerifying the installation¶
You can verify that the packages are correctly installed by running the cell below.
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
print(f'numpy version: {np.__version__}')
print(f'matplotlib version: {matplotlib.__version__}')---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import numpy as np
2 import matplotlib
3 import matplotlib.pyplot as plt
4
ModuleNotFoundError: No module named 'numpy'Deactivating the virtual environment¶
When you are finished working, you can deactivate the virtual environment:
deactivateSummary¶
This lesson covered:
Creating a Python virtual environment using
venv.Activating and deactivating the virtual environment.
Installing the required packages (
numpyandmatplotlib).Verifying the installation.
Now you are ready to proceed to Lesson 1.