Skip to content

Warn when venv target directory already contains an environment #142508

@abdallhfattah

Description

@abdallhfattah

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-venvRelated to the venv moduletype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions