PyCharm 2025.2 Help

Use pyproject.toml

You can specify the project dependencies in the pyproject.toml file inside the project directory. You can create pyproject.toml manually or configure a Poetry environment, so that it's created automatically.

PyCharm provides code completion for packages names and a quick-fix to install the missing dependencies.

Specify project dependencies

  1. Open pyproject.toml in the editor.

  2. Locate or create the [project] section.

  3. Specify the names of the required packages as strings in the dependencies array.

    When you start typing the package name, PyCharm provides completion options:

    Code completion for packages names in pyproject.toml

    Press Enter to insert the suggestion.

You can also provide the optional dependencies of the project in the [project.optional-dependencies] section or specify the build-time dependencies in [build-system.requires].

If the name of the package is highlighted, it means that this package has not been installed for the current Python interpreter.

Install missing packages

  1. Place the caret at the highlighted package name and press Alt+Enter.

  2. Click Install package.

Quick-fixes for installing packages in pyproject.toml

Update .lock file

  1. Open pyproject.toml in the editor.

  2. Edit pyproject.toml to add, remove, or change a dependency.

    If the .lock file becomes outdated, the popup with available actions appears in the upper-right corner of the editor. If it is not visible, hover over the area to reveal the popup.

  3. The available actions depend on the type of environment:

    • Poetry Lock: Update the poetry .lock file to match the dependencies in pyproject.toml.

      Poetry Lock
    • Poetry Update: Install or update dependencies based on pyproject .toml and update the poetry.lock file accordingly.

      Poetry Update

    For more information, refer to Poetry documentation.

    • uv Lock: Upgrade all dependencies to the latest allowed versions and update the uv.lock file.

      uv Lock
    • uv Sync: Update the project's environment to ensure that all dependencies are up to date with the uv.lock file.

      uv Sync

    For more information, refer to uv documentation.

    • Hatch Run: Run the default Hatch environment to install or update packages based on pyproject.toml. If any dependencies have changed, the environment is automatically updated to reflect those changes.

      Hatch Run

    For more information, refer to Hatch documentation.

02 September 2025