Update Python / Django / Modules in a safe way

Step 1: requirements.txt: Activate the current virtual environment, create the requirements.txt file and deactivate the current VE

cd..
virt/scripts/activate
cd fossils
pip freeze > requirements.txt
deactivate

Step 2: Backup: copy your newly created requirements.txt to a safe location.

Step 3: Python: install the latest version of Python in your system. Inside the root directory of your project create the runtime.txt file and inside type: python-installed_version (for example: python-3.10.1)

Step 4: Virtual Environment: Create a new virtual environment with a different name than the existing one.

cd..
python -m venv virtual_new
virt/scripts/activate
cd fossils

Step 5: requirements.txt:




If updating to the newest version of Python and updating all modules crashes the project, simply deactivate the new Virtual Environment and restore the requirements.txt file.

In this case you can create another Virtual Environment, and test each update one at the time.