You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn when running in a virtual environment that was created for a different minor Python version #127727
Environment paths change between minor Python version. When a virtual environment's base Python installation gets updated, the site-packages directories, for eg, will be different, meaning Python won't be able to access any previously installed packages (nor would we want to, as they may be incompatible).
On these situations, we could issue a warning suggesting the user to run python -m venv --upgrade.
Hello. As far as I know, the only way to update the virtual environment's base Python installation is to create a new environment with updated Python, using venv. Then, after installing dependencies required by our project via pip, we migrate project files from the old environment to the new one. That may include pyvenv.cfg which still has information about old environment's Python version.
But before brainstorming, I would like to know one thing: how should the new environment's Python interpreter recognize that it is working with a project from the old environment?
As far as I know, the only way to update the virtual environment's base Python installation is to create a new environment with updated Python, using venv.
You can do this in the same prefix via python -m venv --upgrade.
But before brainstorming, I would like to know one thing: how should the new environment's Python interpreter recognize that it is working with a project from the old environment?
By looking at the version (used by venv) and version_info (used by virtualenv) keys in pyvenv.cfg.
Activity
user21t commentedon Dec 11, 2024
Hello. As far as I know, the only way to update the virtual environment's base Python installation is to create a new environment with updated Python, using
venv. Then, after installing dependencies required by our project viapip, we migrate project files from the old environment to the new one. That may includepyvenv.cfgwhich still has information about old environment's Python version.But before brainstorming, I would like to know one thing: how should the new environment's Python interpreter recognize that it is working with a project from the old environment?
FFY00 commentedon Dec 12, 2024
You can do this in the same prefix via
python -m venv --upgrade.By looking at the
version(used by venv) andversion_info(used by virtualenv) keys inpyvenv.cfg.user21t commentedon Dec 12, 2024
@FFY00 Thank you for explanation.
gh-127727: Warn when running a virtual environment created for a diff…
pythongh-127727: Warn when running a virtual environment created for …