pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.78k stars 1.86k forks source link

pipenv does not update the virtual environment when the python version is updated in the Pipfile #6141

Open Semnodime opened 4 months ago

Semnodime commented 4 months ago

Issue description

pipenv install --python 3.12

Expected result

tail Pipfile -n 2
[requires]
python_version = "3.12"
pipenv run python -V
Python 3.12.2

Actual result

tail Pipfile -n 2
[requires]
python_version = "3.12"
pipenv run python -V
Python 3.10.12

Steps to replicate

pipenv install --python 3.12
mv Pipfile Pipfile.bak
pipenv --rm
pipenv install --python 3.10
mv Pipfile.bak Pipfile
pipenv install --python 3.12
pipenv run python -V
matteius commented 4 months ago

This is expected behavior today. You are welcome to take on improving this logic to detect and prompt use to upgrade their virtualenv (which would be like invoking pipenv --rm and pipenv sync to recreate it.

Semnodime commented 4 months ago

This is expected behavior

The pipenv help suggests otherwise:

Usage Examples:
   Create a new project using Python 3.7, specifically:
   $ pipenv --python 3.7

After a environment has been created with pipenv --python 3.10 , pipenv --python 3.12 won't inform the user that a virtual environment does already exist and won't be upgraded. The command exits with return code 0 which does suggest every wen't without errors. No virtual environment has been created though, in contrast to its internal command description.