包管理器
提示
uv跟npm的特性非常相似
源管理
设置国内镜像源
$ pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple
$ pip3 config set install.trusted-host mirrors.aliyun.com
配置文件位置: ~/.config/pip/pip.conf
配置用户级别的配置文件 ~/.config/uv/uv.toml
或者系统级别的配置文件 /etc/uv/uv.toml
[[index]]
url = "http://mirrors.aliyun.com/pypi/simple/"
default = true
$ go env -w GOPROXY=https://goproxy.cn,direct
$ ; 或者
$ go env -w GOPROXY=https://goproxy.io,direct
$ npm config set registry https://registry.npmmirror.com
获取源信息
$ pip3 config get install.trusted-host
mirrors.aliyun.com
$ go env GOPROXY
https://goproxy.cn,direct
$ npm config get registry
项目初始化
https://docs.astral.sh/uv/guides/projects/#creating-a-new-project
; 在项目根目录执行
$ uv init
https://go.dev/ref/mod#go-mod-init
$ go mod init example.com/m
管理依赖包
安装模块
$ pip install requests==2.31.0
$ # 安装requirements.txt指定的包
$ pip install -r requirements.txt
$ 安装whl文件
$ pip install somewhat.whl
$ uv add requests==2.31.0
$ uv add --dev testcontainers==4.8.2
$ # 安装pyproject.toml指定的包
$ uv sync
$ go get gorm.io/gorm@v1.25.12
https://docs.npmjs.com/cli/v11/commands/npm-install
$ npm install sax
$ # 开发环境依赖
$ npm i -D less
$ # 全局安装
$ npm install -g nodemon
$ # 安装指定版本的包
$ npm i jquery@1.11.2
卸载模块
$ pip uninstall requests
$ npm remove uniq
$ # 全局删除
$ npm r -g nodemon
查看模块
$ # 查看已按照的模块及版本
$ pip freeze
$ pip list
$ # 查看可升级的模块
$ pip list -o