Bits of Python Information
Virtual environment
Main purpose of Python virtual environments is to create an isolated working environment for your projects with different dependencies. Each virtual environment has its own Python binary and can have its own independent set of installed Python packages. You can find more information here and here.
# create virtual environment with the name say project_venv
python3 -m venv project_venv
# activate the environment
source project_venv/bin/activate
# do whatever you need in this isolated environment ...
# deactivate
(project_venv) $ deactivate
Running Script in Interactive Mode
Instead of Python exiting when the program is finished, you can use the -i flag to start an interactive session. This can be useful to inspect global variables or a stack trace when a script raises an exception.
python -i your_script.py