You can run this on a virtual python environment.
Start the virtual environment in the root directory (2d-space-invaders).
Example for MacOS and Linux,
python3 -m venv .venv
Kill the terminal and start a new one. You should now be able to see that you are in a python virtual environment
Then, install pygame using pip,
pip3 install pygame
You should be able to run the game from main.py at this point.
Note that python version 3.10.5 and later does not support pygame at this time.