What happens when venv is run using existing directory

Please consider specifying the behavior of venv module when the ENV_DIR already exists, and/or is not empty and/or contains an existing virtual environment. Currently the docs mentions only: “running this command creates the target directory”, and “creates” implies the command should be executed when ENV_DIR is not present [1].

However, I am able to run python -m venv .venv twice, and there is no error. There is no mention in the docs what happens when the directory is already there. Does venv skips creation of virtual environment? Does it try to create it anyways? What if ENV_DIR content is already a virtual environment? What if it is somewhat broken, does venv try to “fix” it?

[1] On the other hand, there are options --clear, --update, --update-deps, and those imply the ENV_DIR should be present. But it contradicts the previous assumption.

2 Likes

Would you mind opening an issue at GitHub - python/cpython: The Python programming language for this?

2 Likes