UV Global
Create and reuse a global uv environment at ~/.uv-global so you can install Python dependencies for quick, ad hoc scripts without polluting the system interpreter.
Lightning-fast setup that keeps one shared virtual environment ready for temporary tasks.
Use this skill when the user needs Python packages (data processing, scraping, etc.) that are not preinstalled and a full project-specific environment would be overkill. Skip this if the user explicitly wants system Python or a project-local venv.
Requirements
INLINECODE2 available. If missing, you need either brew (macOS/Linux) or curl to install it.
Installation
CODEBLOCK0
The script will:
- - install
uv via brew (macOS/Linux) or the official curl installer if uv is absent - create a global uv project at INLINECODE9
- create a virtual environment with common packages in INLINECODE10
- create a few useful shims in INLINECODE11
[Optional]prepend the venv bin to your PATH so python defaults to the global env and shims are available:
CODEBLOCK1
Usage
For any quick Python script that needs extra dependencies:
CODEBLOCK2
Tips:
- - Keep scripts anywhere; the
--project ~/.uv-global flag ensures they run with the global env. - Inspect installed packages with
uv --project ~/.uv-global pip list. - If a task grows into a real project, switch to a project-local venv instead of this global one.
UV Global
在 ~/.uv-global 下创建并复用全局 uv 环境,以便安装 Python 依赖项用于快速、临时的脚本,而不会污染系统解释器。
闪电般的快速设置,保持一个共享的虚拟环境随时可用于临时任务。
当用户需要未预装的 Python 包(数据处理、爬虫等),且创建完整的项目专属环境过于繁琐时,使用此技能。如果用户明确要求使用系统 Python 或项目本地 venv,则跳过此技能。
要求
需要 uv 可用。如果缺失,你需要 brew(macOS/Linux)或 curl 来安装它。
安装
bash
bash ${baseDir}/install.sh
该脚本将:
- - 如果 uv 不存在,通过 brew(macOS/Linux)或官方 curl 安装程序安装 uv
- 在 ~/.uv-global 创建全局 uv 项目
- 在 ~/.uv-global/.venv 创建包含常用包的虚拟环境
- 在 ~/.uv-global/.venv/bin 创建一些有用的 shim
[可选]将 venv 的 bin 目录添加到你的 PATH 中,这样 python 默认使用全局环境,并且 shim 可用:
export PATH=~/.uv-global/.venv/bin:$PATH
使用方法
对于任何需要额外依赖的快速 Python 脚本:
bash
将所需包安装到全局环境中
uv --project ~/.uv-global add <包名0> <包名1> ...
编写你的代码
touch script.py
使用全局环境运行脚本
uv --project ~/.uv-global run script.py
提示:
- - 脚本可以放在任何位置;--project ~/.uv-global 标志确保它们使用全局环境运行。
- 使用 uv --project ~/.uv-global pip list 检查已安装的包。
- 如果某个任务发展成真正的项目,请切换到项目本地 venv,而不是使用此全局环境。