1. Python Setup

1.1. Install Python

  • Check the version of python installed from the command line.

python --version

1.2. Create a python Virtual environment

Rather than installing the python packages in the system wide installation of python, a virtual environment can be created that only has the modules needed for your project.
Virtual environments allow easy maintenance of the libraries needed for the project and avoid issues that can happen when multiple dependencies conflict across multiple projects.
Create a virtual environment for the packages needed.
By default, these will be created in the users directory: C:\Users\username\.
In examples below, the virtual environment folder will be called: venv_rtd, but any suitable name can be used.
Create a virtual environment, called venv_rtd, with the default system python:
python -m venv venv_rtd
If there are different versions of python installed, use the full path to the version required to create the virtual environment.
<username> used in the paths below will be different for each user.
e.g. C:\Users\username\AppData\Local\Programs\Python\Python311\python.exe
Create a virtual environment using a specific installed version of python:
"C:\Users\username\AppData\Local\Programs\Python\Python311\python.exe" -m venv venv_rtd

1.3. Activate a python Virtual environment

Before you can start installing or using packages in your virtual environment you’ll need to activate it.
Activating a virtual environment will put the virtual environment-specific python and pip executables into your shell’s PATH.
Opening a terminal inside Visual Studio Code will automatically activate the selected virtual environment.
Activate the virtual environment:
"C:\Users\username\venv_rtd\Scripts\activate.bat"

1.4. Using the python Virtual environment in VSCode

VSCode allows the use of different python environments.
To use the python python Virtual environment in VSCode:
  1. Choose View: Command Palette.

  2. Into the drop down search field, type: Python : Select Interpreter

  3. Choose the one listed that refers to the newly created venv_rtd.


1.5. Updating pip

After setting up a project, there may be a need to update the pip.
python.exe -m pip install --upgrade pip

1.6. Installing packages

  • To install a package such as pillow, check the output from typing in the VSCode terminal:

pip install pillow
  • To check the installed version numbers and other info about a package, such as pillow, check the output from typing in the VSCode terminal:

pip show pillow

1.7. Updating packages

  • To update installed packages, such as pillow, to the latest version, run pip install with the –upgrade or -U option.

pip install --upgrade pillow

1.8. List installed packages

  • To get all the installed version numbers, check the output from typing in the VSCode terminal:

pip list
  • To see if there are updates available, check the output from typing in the VSCode terminal:

pip list -o
  • To list updates and those packages that don’t need updates, check the output from typing in the VSCode terminal:

pip list --outdated