Python setup and virtual environment

A Python virtual environment is a self contained environment with a specific Python version and package versions. Different virtual environments can be used for different projects to maintain consistency.

  1. If you haven’t already, download and install Python 3.11 : https://www.python.org/

    1. If you have a different version of Python installed:

      1. Python 3.9 or lower: You must install Python 3.11 (you do not need to uninstall the other version(s)). This is because of a language feature dependency (specifically, match statements introduced in Python 3.10 : https://docs.python.org/3.10/tutorial/controlflow.html#match-statements ).

      2. Python 3.10: You’re probably fine. Probably. Use at your own risk.

      3. Python 3.12 or higher: You’re probably fine. Probably. Use at your own risk.

  2. Open the console in the repository root.

    1. Example: C:\Users\Username\computer-vision-python

  3. Create a virtual environment called venv by running: [python] -m venv venv/ , where [python] is Python 3.11 (e.g. python , python311 ).

    1. You can check which version of Python it is by running [python] --version

    2. If you move the repository to a different path after creating a virtual environment, you will have to delete the venv directory and repeat this step. Additionally, if your virtual environment breaks for any reason, you can always delete the venv directory and repeat this step for a fresh environment.

      1. If you have to change the Python version of your virtual environment, delete it and repeat this step with the new Python version.

    3. Do not use any name other than venv . Otherwise the linters and formatters will break.

Â