python / python/cpython

Warn when `venv` target directory already contains an environment

Open
#142,508 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-venv type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

When a user runs:

python -m venv myenv

and the directory already contains a virtual environment, Python silently performs no action. This behavior can be confusing, as the user receives no indication that the command had no effect.

I propose that venv should display a simple warning when it detects an existing virtual environment so the user knows the operation didn’t make any changes.

Example of the suggested output:

$ python -m venv myenv
Existing virtual environment found at 'myenv'.
No changes were made.
Use '--clear' to recreate this environment.

This provides clarity while keeping behavior backward-compatible. Users who want to recreate the environment can explicitly use --clear.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the python -m venv entry point and compare its behavior when the target directory already contains an environment. Verify how the existing --clear option changes that behavior. Done means an existing environment produces the proposed warning and reports that no changes were made, while explicit clearing remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.