2. Python
2.1. Install Python
Check the version of python installed from the command line.
python --version
Download and install Python from https://www.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.
2.2. Create a python Virtual environment
C:\Users\USERNAME\
, where USERNAME
is replaced by hte 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.bat"
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==7.2.6
sphinx-copybutton==0.5.2
sphinx-rtd-theme==1.3.0
sphinx-togglebutton==0.3.2
sphinx_design==0.5.0
pip install Sphinx==7.2.6
pip install sphinx-copybutton==0.5.2
pip install sphinx-rtd-theme==1.3.0
pip install sphinx-togglebutton==0.3.2
pip install sphinx_design==0.5.0
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 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
-U
can 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 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
2.7. Save package list to requirements file
requirements.txt
file can be saved and used to create a new venv:pip freeze > requirements.txt
2.8. Updating python packages
powershell
in the Search Box of the Windows Task bar.pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
2.9. Uninstalling all python packages
pip freeze | xargs pip uninstall -y
2.10. Update virtual Venvironment python in place
python -m venv --upgrade "C:\Users\USERNAME\VENVNAME"
2.11. Update virtual Venvironment 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