python / python/cpython

Warn when `venv` target directory already contains an environment

未关闭
#142,508 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stdlib topic-venv type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

python -m venv 入口点开始,比较目标目录中已经包含环境时的行为。验证现有的 --clear 选项如何改变该行为。当现有环境产生提议的警告并报告未进行任何更改,同时显式清除仍然可用时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
cli
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。