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
Open pyproject.toml in the editor.
Locate or create the
[project]
section.Specify the names of the required packages as strings in the
dependencies
array.When you start typing the package name, PyCharm provides completion options:
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
Place the caret at the highlighted package name and press Alt+Enter.
Click Install package.