Skip to content

Commit fefa13f

Browse files
committed
Initial commit: Python Environment Reset Tool v1.0.0
0 parents  commit fefa13f

7 files changed

Lines changed: 639 additions & 0 deletions

File tree

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Virtual Environments
24+
.venv/
25+
venv/
26+
env/
27+
.env/
28+
ENV/
29+
env.bak/
30+
venv.bak/
31+
32+
# IDE
33+
.vscode/
34+
.idea/
35+
*.swp
36+
*.swo
37+
*~
38+
39+
# OS
40+
.DS_Store
41+
Thumbs.db
42+
desktop.ini
43+
44+
# Temporary files
45+
temp_packages.txt
46+
*.tmp
47+
*.bak
48+
49+
# Project specific
50+
requirements.txt.bak

CHANGELOG.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2025-12-02
9+
10+
### Added
11+
- 🎉 Initial release of Python Environment Reset Tool
12+
- ✨ Automatic virtual environment detection (`.venv`, `venv`, `env`, `.env`)
13+
- 🛡️ Safety warnings for global Python environment operations
14+
- 📦 Complete package uninstallation with user confirmation
15+
- 🔧 Automatic base packages installation (pip, setuptools, wheel)
16+
- 🌐 Full UTF-8 support for international characters
17+
- 📝 Clear and informative console output
18+
- ⚠️ Error handling and validation
19+
- 🎯 User-friendly prompts and confirmations
20+
- 📋 Display of current Python environment and installed packages
21+
- 💡 Helpful hints for requirements.txt installation
22+
23+
### Features
24+
- Detects and activates virtual environments automatically
25+
- Lists all installed packages before uninstallation
26+
- Requires explicit confirmation before destructive operations
27+
- Upgrades pip to the latest version
28+
- Installs essential build tools (setuptools, wheel)
29+
- Shows final package list after reset
30+
- Provides guidance for next steps
31+
32+
### Security
33+
- Strong warnings when operating on global Python environment
34+
- Requires typing "YES" in uppercase for global environment operations
35+
- Multiple confirmation steps to prevent accidental data loss
36+
37+
---
38+
39+
## Release Notes
40+
41+
### What's New in v1.0.0
42+
43+
This is the first stable release of the Python Environment Reset Tool! 🎊
44+
45+
**Key Highlights:**
46+
- Simple one-click solution to reset your Python virtual environment
47+
- Smart detection of common virtual environment folder names
48+
- Safety-first approach with multiple warnings and confirmations
49+
- Clean, professional console interface with UTF-8 support
50+
- Automatic reinstallation of essential Python packages
51+
52+
**Perfect for:**
53+
- Developers who need to clean up their virtual environments
54+
- Troubleshooting package conflicts
55+
- Starting fresh with a clean Python environment
56+
- Testing package installations
57+
58+
**Getting Started:**
59+
1. Download `env-reset.bat`
60+
2. Place it in your project directory
61+
3. Double-click to run
62+
4. Follow the prompts
63+
64+
Thank you for using Python Environment Reset Tool! 🐍✨

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Python Environment Reset Tool
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# Python Environment Reset Tool | Python 环境重置工具
2+
3+
[English](#english) | [中文](#chinese)
4+
5+
---
6+
7+
<a name="english"></a>
8+
## 🌟 English
9+
10+
### Overview
11+
12+
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.
13+
14+
### ✨ Features
15+
16+
- 🔍 **Auto-Detection**: Automatically detects common virtual environment directories (`.venv`, `venv`, `env`, `.env`)
17+
- 🛡️ **Safety First**: Warns users when operating on global Python environment
18+
- 📦 **Clean Reset**: Uninstalls all packages and reinstalls base packages (pip, setuptools, wheel)
19+
- 🎯 **User-Friendly**: Clear prompts and confirmations before any destructive operations
20+
- 🌐 **UTF-8 Support**: Properly handles Chinese and other Unicode characters
21+
22+
### 📋 Requirements
23+
24+
- Windows OS
25+
- Python 3.x installed and accessible via `python` command
26+
- pip package manager
27+
28+
### 🚀 Quick Start
29+
30+
1. **Download** the `env-reset.bat` file
31+
2. **Place** it in your Python project root directory (where your virtual environment folder is)
32+
3. **Run** by double-clicking `env-reset.bat` or executing it in command prompt
33+
34+
```batch
35+
env-reset.bat
36+
```
37+
38+
### 📖 Usage
39+
40+
#### For Virtual Environment (Recommended)
41+
42+
```bash
43+
# Create a virtual environment first (if you haven't)
44+
python -m venv .venv
45+
46+
# Run the reset tool
47+
env-reset.bat
48+
```
49+
50+
The script will:
51+
1. Detect and activate your virtual environment
52+
2. List all installed packages
53+
3. Ask for confirmation
54+
4. Uninstall all packages
55+
5. Upgrade pip and install base packages
56+
57+
#### For Global Environment (Not Recommended)
58+
59+
If no virtual environment is detected, the script will:
60+
1. Display a **strong warning**
61+
2. Require explicit confirmation (type `YES` in uppercase)
62+
3. Proceed only if confirmed
63+
64+
### 🔧 Supported Virtual Environment Names
65+
66+
- `.venv` (recommended)
67+
- `venv`
68+
- `env`
69+
- `.env`
70+
71+
### ⚠️ Important Notes
72+
73+
- **Always use virtual environments** for project development
74+
- The script will **not** delete the virtual environment folder itself
75+
- Base packages (pip, setuptools, wheel) are automatically reinstalled
76+
- If `requirements.txt` exists, you'll be reminded to reinstall project dependencies
77+
78+
### 📝 Example Output
79+
80+
```
81+
==========================================
82+
虚拟环境重置工具
83+
==========================================
84+
85+
检测到虚拟环境: .venv
86+
87+
当前 Python 环境:
88+
------------------------------------------
89+
C:\Project\.venv\Scripts\python.exe
90+
Python 3.11.0
91+
------------------------------------------
92+
93+
==========================================
94+
获取已安装包列表
95+
==========================================
96+
97+
当前已安装的包:
98+
------------------------------------------
99+
requests==2.31.0
100+
numpy==1.24.0
101+
------------------------------------------
102+
103+
确认卸载以上所有包?(Y/N): Y
104+
105+
==========================================
106+
✓ 环境重置完成!
107+
==========================================
108+
```
109+
110+
### 🤝 Contributing
111+
112+
Contributions, issues, and feature requests are welcome!
113+
114+
### 📄 License
115+
116+
MIT License - feel free to use this tool in your projects.
117+
118+
### 👤 Author
119+
120+
Created with ❤️ for Python developers
121+
122+
---
123+
124+
<a name="chinese"></a>
125+
## 🌟 中文
126+
127+
### 项目简介
128+
129+
一个轻量级的 Windows 批处理脚本工具,用于安全地重置 Python 虚拟环境。它能自动检测并激活虚拟环境,卸载所有包,并重新安装必要的基础包。
130+
131+
### ✨ 功能特性
132+
133+
- 🔍 **自动检测**:自动检测常见的虚拟环境目录(`.venv``venv``env``.env`
134+
- 🛡️ **安全优先**:在操作全局 Python 环境时会发出强烈警告
135+
- 📦 **彻底清理**:卸载所有包并重新安装基础包(pip、setuptools、wheel)
136+
- 🎯 **用户友好**:在执行任何破坏性操作前都有清晰的提示和确认
137+
- 🌐 **UTF-8 支持**:正确处理中文和其他 Unicode 字符
138+
139+
### 📋 系统要求
140+
141+
- Windows 操作系统
142+
- 已安装 Python 3.x 并可通过 `python` 命令访问
143+
- pip 包管理器
144+
145+
### 🚀 快速开始
146+
147+
1. **下载** `env-reset.bat` 文件
148+
2. **放置** 到你的 Python 项目根目录(虚拟环境文件夹所在位置)
149+
3. **运行** 双击 `env-reset.bat` 或在命令提示符中执行
150+
151+
```batch
152+
env-reset.bat
153+
```
154+
155+
### 📖 使用方法
156+
157+
#### 虚拟环境模式(推荐)
158+
159+
```bash
160+
# 首先创建虚拟环境(如果还没有)
161+
python -m venv .venv
162+
163+
# 运行重置工具
164+
env-reset.bat
165+
```
166+
167+
脚本将会:
168+
1. 检测并激活你的虚拟环境
169+
2. 列出所有已安装的包
170+
3. 请求确认
171+
4. 卸载所有包
172+
5. 升级 pip 并安装基础包
173+
174+
#### 全局环境模式(不推荐)
175+
176+
如果未检测到虚拟环境,脚本将:
177+
1. 显示**强烈警告**
178+
2. 要求明确确认(输入大写的 `YES`
179+
3. 仅在确认后才继续执行
180+
181+
### 🔧 支持的虚拟环境名称
182+
183+
- `.venv`(推荐)
184+
- `venv`
185+
- `env`
186+
- `.env`
187+
188+
### ⚠️ 重要提示
189+
190+
- **始终使用虚拟环境**进行项目开发
191+
- 脚本**不会**删除虚拟环境文件夹本身
192+
- 基础包(pip、setuptools、wheel)会自动重新安装
193+
- 如果存在 `requirements.txt`,会提醒你重新安装项目依赖
194+
195+
### 📝 输出示例
196+
197+
```
198+
==========================================
199+
虚拟环境重置工具
200+
==========================================
201+
202+
检测到虚拟环境: .venv
203+
204+
当前 Python 环境:
205+
------------------------------------------
206+
C:\Project\.venv\Scripts\python.exe
207+
Python 3.11.0
208+
------------------------------------------
209+
210+
==========================================
211+
获取已安装包列表
212+
==========================================
213+
214+
当前已安装的包:
215+
------------------------------------------
216+
requests==2.31.0
217+
numpy==1.24.0
218+
------------------------------------------
219+
220+
确认卸载以上所有包?(Y/N): Y
221+
222+
==========================================
223+
✓ 环境重置完成!
224+
==========================================
225+
```
226+
227+
### 🤝 贡献
228+
229+
欢迎贡献代码、提出问题和功能请求!
230+
231+
### 📄 许可证
232+
233+
MIT 许可证 - 可自由在你的项目中使用此工具。
234+
235+
### 👤 作者
236+
237+
用 ❤️ 为 Python 开发者创建
238+
239+
---
240+
241+
## 🌐 Links
242+
243+
- [Report Bug](../../issues)
244+
- [Request Feature](../../issues)
245+
246+
## ⭐ Star History
247+
248+
If you find this tool helpful, please consider giving it a star!

0 commit comments

Comments
 (0)