Files
Obsidian/MyBestNanobot/Nanobot帮我搞好的Python多版本切换.md
coco 8b94d76799 a
2026-07-21 13:57:15 +08:00

62 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## ✅ **Python 3.12 安装完成!**
### **🎉 多版本并存状态**
| 版本 | 路径 | pip | 状态 |
|------|------|-----|------|
| **Python 3.12.2** ✅ | `/usr/local/bin/python3.12` | 26.0.1 | 最新版 |
| Python 3.9.5 | `/usr/bin/python3.9` | 26.0.1 | 可选 |
| Python 3.8.10 | `/usr/bin/python3.8` | 25.0.1 | 系统默认 |
---
### **🔄 版本切换方法**
```bash
# 1️⃣ 查看所有版本
~/pyenv-manager list
# 2️⃣ 切换系统默认(3.8 ↔ 3.9)
~/pyenv-manager switch 3.9
# 3️⃣ 直接使用特定版本
python3.12 script.py # Python 3.12
python3.9 script.py # Python 3.9
python3.8 script.py # Python 3.8
# 4️⃣ 安装包到指定版本
python3.12 -m pip install requests
```
---
### **📦 已配置工具**
| 文件 | 功能 |
|------|------|
| `~/pyenv-manager` | 版本管理工具(list/switch/venv/install/test) |
| `~/.python-versions` | 快捷别名(py312, py39, pip312...) |
| `~/PYTHON_VERSIONS_GUIDE.md` | 完整使用指南 |
---
### **⚡ 快速开始**
```bash
# 测试 Python 3.12
python3.12 -c "import sys; print(f'Hello Python {sys.version_info.major}.{sys.version_info.minor}')"
# 创建虚拟环境
python3.12 -m venv myproject312
source myproject312/bin/activate
```
---
### **⚠️ 重要说明**
- `python3` 仍指向系统默认(3.8/3.9)→ **不影响系统稳定**
- Python 3.12 需使用 `python3.12` 命令调用
- 所有版本独立,pip 互不干扰
需要我展示更多用法吗?🐈