Hachi Blog
2026-02-20

uvでPython環境構築

#python #uv #tech

uvの導入方法をまとめておく。

参考

https://docs.astral.sh/uv/

導入方法

WSL Ubuntu24.04へのインストール方法は、公式ドキュメント通り。

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

上記コマンドを実行すると、~/.bashrcの末尾に. "$HOME/.local/bin/env" が追加されていて、自動でuvのPATHを通してくれる。

よく利用するコマンドたち

# install python
uv python install 3.12

# list installed python
uv python list

# create project
uv init

# install package in project
uv add <package>

# run script
uv run main.py