2. Python
2.1. Install Python
Download and install Python from: https://www.python.org/downloads/.
Older versions can be found at: https://test.python.org/downloads/.
Check the checkbox to update the path variable when installing.
Manually update path if it wasn’t automatically done during installation.
In windows search enter “edit the system environment variables” to edit the environment variables.
Edit the path variable to include the path to the installed python version.
Restart is usually needed to update the system path.
Check the version of python installed from the command line.
python --version
import sys
print("Python version")
print(sys.version)
print("Version info.")
print(sys.version_info)
print("Python Path")
print(sys.executable)
2.2. Create a python Virtual environment
C:\Users\USERNAME\, where USERNAME is replaced by the user.VENVNAME, but any suitable name can be used.python -m venv VENVNAME
C:\Users\USERNAME\AppData\Local\Programs\Python\Python312\python.exe"C:\Users\USERNAME\AppData\Local\Programs\Python\Python312\python.exe" -m venv VENVNAME
"C:\Users\USERNAME\VENVNAME\Scripts\activate"
2.3. Using the python Virtual environment in VSCode
Choose View: Command Palette.
Into the drop down search field, type: Python : Select Interpreter
Choose the one listed that refers to the newly created VENVNAME.
2.4. Update pip
python.exe -m pip install --upgrade pip
2.5. Install python packages via requirements.txt
requirements.txt, into the virtual environment folder.sphinx==8.2.3
sphinx-copybutton
sphinx-rtd-theme
sphinx-togglebutton
sphinx_design
sphinx-new-tab-link
pip install Sphinx==8.2.3
pip install sphinx-copybutton
pip install sphinx-rtd-theme
pip install sphinx-togglebutton
pip install sphinx_design
pip install sphinx-new-tab-link
pip install -r "C:\Users\USERNAME\VENVNAME\requirements.txt"
"C:\Users\USERNAME\" then use this:pip install -r "VENVNAME\requirements.txt"
"C:\Users\USERNAME\VENVNAME\" then use this:pip install -r "requirements.txt"
2.6. Updating python packages
cd VENVNAME
pip install --upgrade package_name
-Ucan be used instead of--upgrade
pip install -U package_name
2.7. Updating python packages in a requirements file
requirements.txt file.cd to the folder with the requirements.txt file and use:cd VENVNAME
pip install --upgrade -r requirements.txt
-Ucan be used instead of--upgrade
pip install -U -r requirements.txt
To check the installed version numbers and other info about a package, check the output from typing in the VSCode terminal:
pip show sphinx
pip show sphinx_rtd_theme
pip show sphinx-copybutton
pip show sphinx-togglebutton
pip show sphinx_design
pip show sphinx-new-tab-link
pip show docutils
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
or
pip list --outdated
2.8. Save package list to requirements file
requirements.txt file can be saved and used to create a new venv:pip freeze > requirements.txt
2.9. Updating python packages
powershell in the Search Box of the Windows Task bar.pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
2.10. Uninstalling all python packages
pip freeze | xargs pip uninstall -y
2.11. Update virtual environment python in place
python -m venv --upgrade "C:\Users\USERNAME\VENVNAME"
2.12. Update virtual environment by reinstalling it
Deactivate the virtual environment if it’s currently active. You can do this by typing deactivate in your terminal and pressing Enter.
Navigate ot the directory in the terminal. e.g. cd C:/Users/USERNAME/
Delete the virtual environment. Be careful with this step as it will remove all the packages installed in the virtual environment. You can do this by typing Remove-Item -Path VENVNAME -Recurse in your powershell terminal and pressing Enter.
Create a new virtual environment with the updated Python version. You can do this by typing python -m venv VENVNAME in your terminal and pressing Enter.
Activate the new virtual environment. You can do this by typing C:UsersUSERNAMEVENVNAMEScriptsactivate.bat in your terminal and pressing Enter.
Install the required packages. Place a requirements.txt file that lists all the packages you need. You can do this by typing pip install -r requirements.txt in your terminal and pressing Enter.
deactivate
cd C:\Users\USERNAME
Remove-Item -Path VENVNAME -Recurse
python -m venv VENVNAME
C:\Users\USERNAME\VENVNAME\Scripts\activate.bat
cd C:\Users\USERNAME\VENVNAME
pip install -r requirements.txt