Install Python interpreter
Python interpreter is the program that will run our actual Python code. The default downloaded interpreter is also called “base interpreter”, and for each project it’s recommended to open a new virtual environment (“venv”) with its own “project interpreter”.
- Download Python.
- As of the end of 2022 I recommend Python 3.10.8 64bit installer .exe from: https://www.python.org/downloads/release/python-3108/ (“Files” at the bottom of page).
Open installer -> check the “add Python 3.X to Path” -> click “Install Now” -> press “next” as needed until finish.
Test your installation: open CMD -> type
Create a virtual environment
A virtual environment (venv for short) is a way to have multiple instances of the Python interpreter, each with different package sets and different configurations. This is a standart procedure when working on several different projects and every python developer should use it.
Building a venv is easy:
- Create a new venv folder:
python -m venv <venv_name>.
- I recommend you build the venv dir inside the project dir.
- Activate the venv:
- Unix/ MacOS:
- Note that the venv name is now appearing in the start of the cmd lines:
Install python packages
Packages are the main way to get nontrivial functions that we are going to use, like:
numpy: for matrix and vector operations.
matplotlib: for graph visualization.
cv2: for image processing tasks.
pytorch: for neural networks.
- Make sure we are in our activated venv.
- Install packages with
pip install <package_name>:
pip install matplotlib(will also install numpy…)
pip install torch(a GPU enabled package also exists, but it’s hard so we will skip it for now)
pip install opencv-python(this is
Test the installation inside python:
import torch import numpy as np import matplotlib.pyplot as plt import cv2 print("hello world")
If all installation went well, you should see “hello world” in the cmd.
Working only on the CMD is hard… We will use VSCode which is our Integrated development environment (IDE) of choice. This will give us syntax highlighting, debugging and much more.
- Install VSCode https://code.visualstudio.com/
- Install the python extansion inside VSCode:
- Open our project directory in VSCode and create a new
- Select our Python interpreter by opening the Command Palette (Ctrl+Shift+P) and type
Python: Select Interpreter, and select our venv.
- You can run the code in debug mode using
F5. More about it here.