Ubuntu下安装cargo和uv(其实直接可以pip安装uv)
先上结论,走了弯路了,Ubuntu里不需要安装cargo(使用cargo安装uv),直接在pip里安装uv就行了。
uv 是一个非常快的Python包安装和解析器,用Rust编写。 设计为代替 pip和pip-tools 的工具。 替代方案: 可完全替代常用的 pip、pip-tools 和 virtualenv 命令。 超快速度: 比 pip 和 pip-tools (pip-compile 和 pip-sync) 快 10-100 倍。 节省磁盘空间: 具有全局缓存,可重复使用依赖项,节省磁盘空间。
弯路
安装cargo
先安装cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
或者
sudo apt install cargo
然后在cargo安装uv
直接使用命令:
cargo install --git https://github.com/astral-sh/uv uv
失败
直接使用pip安装uv
pip安装
pip install uv
使用uv
使用前,先创建一个虚拟环境
uv venv py310
好了,后面就可以使用uv来安装python包了,比如
uv pip install -r requirements.txt
调试
cargo安装uv报错
cargo install --git https://github.com/astral-sh/uv uv
Updating git repository `https://github.com/astral-sh/uv`
error: cannot install package `uv 0.6.1`, it requires rustc 1.83 or newer, while the currently active rustc version is 1.75.0
ubuntu22下最高版本就是1.80,先试试
sudo apt install rustc-1.80
升级的时候提示:
Newer kernel available │
│ │
│ The currently running kernel version is 5.15.0-127-generic which is not the expected kernel version │
│ 5.15.0-131-generic. │
│ │
│ Restarting the system to load the new kernel will not be handled automatically, so you should consider │
│ rebooting. │
│ │
│ <Ok>
1.80还是不行,就是要1.83
放弃这种方法,直接使用pip安装。