Python環境をuvで構築

https://github.com/astral-sh/uv

uvが流行っているらしいので使ってみる。


uv自体のinstall

# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh


pythonのinstall

uv python install
Installed Python 3.13.5 in 5.56s
+ cpython-3.13.5-macos-aarch64-none


でプロジェクトを初期化

cd project_dir
uv init

以下のようなディレクトリが作成される。

.
├── README.md
├── main.py
├── pyproject.toml
└── uv.lock


この状態で以下のようにmain.pyを実行

uv run main.py
Using CPython 3.13.5
Creating virtual environment at: .venv
Hello from neet-code-python!

最低限は完了

Related Articles