Setting up your Python environment

View notebooks on Github

Author: Alejandro Monroy

To be able to run the notebooks, you need to install Python 3.13 and the libraries in the following requirements file. It is a good practice to create a virtual environment using venv or conda, preventing version conflicts with other projects or system-wide installations.

You can verify that your have the correct version of the libraries (or newer) by running the following cell:

[1]:
import sys
import ipykernel
import matplotlib
import numpy
import pandas
import sklearn
import seaborn

required_python_version = "3.13"
installed_python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
assert installed_python_version.startswith(required_python_version), (
    f"Python version mismatch: installed {installed_python_version}, required {required_python_version}.x"
)

versions = {
    "ipykernel": {"required": "6.31.0", "installed": ipykernel.__version__},
    "matplotlib": {"required": "3.10.6", "installed": matplotlib.__version__},
    "numpy": {"required": "2.3.5", "installed": numpy.__version__},
    "pandas": {"required": "2.3.3", "installed": pandas.__version__},
    "scikit-learn": {"required": "1.7.2", "installed": sklearn.__version__},
    "seaborn": {"required": "0.13.2", "installed": seaborn.__version__}
}

for library, version_info in versions.items():
    required_version = version_info["required"]
    installed_version = version_info["installed"]
    assert installed_version >= required_version, f"{library} version mismatch: installed {installed_version}, required {required_version}"

In case you do encounter an error due to an older or newer version of these packages, you can use the following prompt in the command line to install the specific versions of each package. If you use a seperate environment for this course, be sure to run this code in said environment. You can use the activate command to switch environments in the command line.

[ ]:
pip install ipykernel==6.31.0 && pip install matplotlib==3.10.6 && pip install numpy==2.3.5 && pip install pandas==2.3.3 && pip install scikit-learn==1.7.2 && pip install seaborn==0.13.2