A lightweight Windows batch script tool for safely resetting Python virtual environments. It automatically detects and activates virtual environments, uninstalls all packages, and reinstalls essential base packages.
- 🔍 Auto-Detection: Automatically detects common virtual environment directories (
.venv,venv,env,.env) - 🛡️ Safety First: Warns users when operating on global Python environment
- 📦 Clean Reset: Uninstalls all packages and reinstalls base packages (pip, setuptools, wheel)
- 🎯 User-Friendly: Clear prompts and confirmations before any destructive operations
- 🌐 UTF-8 Support: Properly handles Chinese and other Unicode characters
- Windows OS
- Python 3.x installed and accessible via
pythoncommand - pip package manager
- Download the
env-reset.batfile - Place it in your Python project root directory (where your virtual environment folder is)
- Run by double-clicking
env-reset.bator executing it in command prompt
env-reset.bat# Create a virtual environment first (if you haven't)
python -m venv .venv
# Run the reset tool
env-reset.batThe script will:
- Detect and activate your virtual environment
- List all installed packages
- Ask for confirmation
- Uninstall all packages
- Upgrade pip and install base packages
If no virtual environment is detected, the script will:
- Display a strong warning
- Require explicit confirmation (type
YESin uppercase) - Proceed only if confirmed
.venv(recommended)venvenv.env
- Always use virtual environments for project development
- The script will not delete the virtual environment folder itself
- Base packages (pip, setuptools, wheel) are automatically reinstalled
- If
requirements.txtexists, you'll be reminded to reinstall project dependencies
==========================================
虚拟环境重置工具
==========================================
检测到虚拟环境: .venv
当前 Python 环境:
------------------------------------------
C:\Project\.venv\Scripts\python.exe
Python 3.11.0
------------------------------------------
==========================================
获取已安装包列表
==========================================
当前已安装的包:
------------------------------------------
requests==2.31.0
numpy==1.24.0
------------------------------------------
确认卸载以上所有包?(Y/N): Y
==========================================
✓ 环境重置完成!
==========================================
Contributions, issues, and feature requests are welcome!
MIT License - feel free to use this tool in your projects.
Created with ❤️ for Python developers
一个轻量级的 Windows 批处理脚本工具,用于安全地重置 Python 虚拟环境。它能自动检测并激活虚拟环境,卸载所有包,并重新安装必要的基础包。
- 🔍 自动检测:自动检测常见的虚拟环境目录(
.venv、venv、env、.env) - 🛡️ 安全优先:在操作全局 Python 环境时会发出强烈警告
- 📦 彻底清理:卸载所有包并重新安装基础包(pip、setuptools、wheel)
- 🎯 用户友好:在执行任何破坏性操作前都有清晰的提示和确认
- 🌐 UTF-8 支持:正确处理中文和其他 Unicode 字符
- Windows 操作系统
- 已安装 Python 3.x 并可通过
python命令访问 - pip 包管理器
- 下载
env-reset.bat文件 - 放置 到你的 Python 项目根目录(虚拟环境文件夹所在位置)
- 运行 双击
env-reset.bat或在命令提示符中执行
env-reset.bat# 首先创建虚拟环境(如果还没有)
python -m venv .venv
# 运行重置工具
env-reset.bat脚本将会:
- 检测并激活你的虚拟环境
- 列出所有已安装的包
- 请求确认
- 卸载所有包
- 升级 pip 并安装基础包
如果未检测到虚拟环境,脚本将:
- 显示强烈警告
- 要求明确确认(输入大写的
YES) - 仅在确认后才继续执行
.venv(推荐)venvenv.env
- 始终使用虚拟环境进行项目开发
- 脚本不会删除虚拟环境文件夹本身
- 基础包(pip、setuptools、wheel)会自动重新安装
- 如果存在
requirements.txt,会提醒你重新安装项目依赖
==========================================
虚拟环境重置工具
==========================================
检测到虚拟环境: .venv
当前 Python 环境:
------------------------------------------
C:\Project\.venv\Scripts\python.exe
Python 3.11.0
------------------------------------------
==========================================
获取已安装包列表
==========================================
当前已安装的包:
------------------------------------------
requests==2.31.0
numpy==1.24.0
------------------------------------------
确认卸载以上所有包?(Y/N): Y
==========================================
✓ 环境重置完成!
==========================================
欢迎贡献代码、提出问题和功能请求!
MIT 许可证 - 可自由在你的项目中使用此工具。
用 ❤️ 为 Python 开发者创建
If you find this tool helpful, please consider giving it a star!