How to update the Python version in a Django project with pipenv?

Hi guys!

Thank you very much for your help.

This is what I did based on the YouTube tutorial I posted above (link). And also the Pipenv documentation.

There are actually two ways to solve this:

  1. Update Pipfile.
  • You determine the python version you need in Pipfile, in this case I specify version 3.9 (which is already installed in the global directory)
[requires]
python_version = "3.9" 
  • You then run:
pipenv --python 3.9 

You’re telling pipenv that the environment should be recreated with this Python version.

  1. Remove the virtual environment and re install everything.
  • You first update Pipfile as in the first case.
  • Then you remove the virutal environment
pipenv -rm
  • And finally you re install:
pipenv install

It will install the Python version selected in Pipfile and the other dependencies.