uv 環境を構成する
uv(英語) ツールを使用すると、Python の開発が容易になり、新しいプロジェクトのセットアップタスクが削減され、既存のプロジェクトの管理が容易になります。
PyCharm で uv を使用するには、 マシンにインストールし、特定の Python 環境を作成する必要があります。
新しい Python プロジェクトの作成中に uv を選択すると、PyCharm が自動的に pyproject.tomlファイルを生成します。 このファイルには、必要なパッケージ、スクリプト、プラグイン、URL が指定されています。 ファイルの構造と形式の詳細については、 pyproject(英語) ガイドを参照してください。
uv 環境を作成する
次のいずれかを実行します:
Python インタープリターセレクターをクリックして 新しいインタープリターを追加 を選択します。
Ctrl+Alt+S を押して 設定 を開き、 に移動します。
Python インタープリターセレクターをクリックして インタープリターの設定 を選択します。 利用可能なインタープリターのリストの横にある インタープリターの追加 リンクをクリックします。
利用可能なインタープリターのリストの横にある インタープリターの追加 リンクをクリックし、 ローカルインタープリターを追加する を選択します。
次のアクションは、新しい仮想環境を生成するか、既存の仮想環境を使用するかによって異なります。
- 新しい uv 環境

環境タイプのリストから uv を選択します。
リストから Python のバージョンを選択します。
PyCharm は uv のインストールを検出します。
PyCharm がインストールを自動的に検出しなかった場合は、uv 実行可能ファイルの場所を指定するか、
をクリックして参照します。
- 既存の uv 環境

環境タイプのリストから uv を選択します。
PyCharm は uv のインストールを検出します。
PyCharm がインストールを自動的に検出しなかった場合は、uv 実行可能ファイルの場所を指定するか、
をクリックして参照します。
リストから環境を選択します。
選択した uv 環境は、現在のプロジェクトで再利用されます。
タスクを完了するには、 OK をクリックしてください。
UV 環境を構成したら、ターミナルまたは uv 実行 / デバッグ構成を使用してプロジェクトを実行できます。
uv workspace support
PyCharm supports uv workspaces and uv path dependencies. When you open a project with the Workspace mode enabled, PyCharm automatically sets up the workspace members and their dependencies.
uv workspaces use a single virtual environment shared across all projects, while uv path dependencies give each project its own virtual environment.
Once a .py or pyproject.toml file is opened in a workspace member, PyCharm checks whether an environment for this workspace already exists on the system. If it does, the environment is automatically set as the SDK. If not, a file-level notification suggests creating a new uv environment and installing dependencies for this workspace member.
PyCharm verifies environment consistency and warns you if a dependency defined in pyproject.toml is missing from the environment. A quick-fix is provided to install the missing dependency. If a package is imported but not listed in the workspace member's pyproject.toml , a quick-fix will suggest adding the package to the environment and updating the corresponding .toml file.
The dependencies between workspace members are visually presented in as read-only. To make changes, edit the pyproject.toml file manually.
詳細については、 Workspaces and monorepos を参照してください。
構成された Python インタープリター (ただし Docker ベース) のいずれかに対して、次の操作を実行できます。