Start typing the package name in the search field of the Python Packages tool window. The matching packages are displayed.
If the current Python interpreter is a conda virtual environment, the packages available in the conda package repository are also displayed.
Select the package and then do one of the following:
. Click Install next to the package name and choose the version.
. Choose the version from the list of available versions and click Install.
You can use the pip install command-line options during the installation:
. Right-click next to the package name and select Install with Options.
. In the dialog that opens, enter the required options and click OK.
Packages installed with conda or pip are marked with the corresponding icons.
If a popup with an error message appears, refer to the Troubleshooting guide for a solution.
Install packages
If the current Python interpreter is a conda virtual environment, the packages available in the conda package repository are also displayed.
. Choose the version from the list of available versions and click Install.
You can use the pip install command-line options during the installation: . Right-click next to the package name and select Install with Options. . In the dialog that opens, enter the required options and click OK. Packages installed with conda or pip are marked with the corresponding icons.
在项目的main的文件夹上(如果你的代码都放到main中的话)点击右键,如下图
然后在 Mark Directory as --> Sources Root,如下图:
这是一种可能的原因,仅供参考。