快轉到主要內容
  1. Note/

Life Is Short Use 'uv'

·1 分鐘· ·
目錄
封面來自 uv 官方文件

Life Is Short Use uv
#

An extremely fast Python package and project manager, written in Rust.

只有 可以形容uv 用過就回不去 poetry 了 !

下載
#

curl -LsSf https://astral.sh/uv/install.sh | sh

使用
#

管理虛擬環境
#

會產生虛擬環境在 .venv 資料夾

uv python pin 3.12
uv venv

# or inline command
uv venv --python 3.12

安裝套件
#

同步 pyproject.toml 的 dependencies 到虛擬環境

uv sync

安裝套件

uv add requests

pip 介面
#

uv 有提供 pip 的介面

uv pip install -r requirements.txt

常見問題
#

MacOS 預設的 ulimit 設定 ( 預設 256 ) 對於開啟的 file descriptor 數量來說太低了
這在安裝時可能會遇到 Too many open files 的錯誤。

可以修改 file descriptor 的限制,如把它設定為 2048 :

ulimit -n 2048

相關文章