pycharm cannot find the installed library
1. Appears when installing python and pycharm
1. I installed python on the C drive and pycharm on the D drive.
Enter at the cmd command prompt line
python -m pip list
Then the installed python library is displayed
, but the installed library cannot be found in pycharm. For example, as shown below:
Check the installed library and find that it is not the same as the library installed on the C drive.
Reason: The python selected when building the project is not the one you installed.
We first find the specific location of the library installed on the C drive:
taking the pygame package as an example:
enter:
pip show pygame
The display in cmd is as follows:
Find the corresponding location in the C drive, and you can also see the location of the python interpreter:
You can see that the packages are all installed.
Then we go to pycharm.
Click settings->python interpreter
and you can see that the python 3.9 here is different from the location installed in the C drive.
Click Add interpreter and then add the location corresponding to the previous C drive. There are two options at this time.
Select the other one to display many installed packages:
Then select it to achieve:
no errors will appear at this time.
Then I went to look at the time and date of the first corresponding python.exe
as shown in the figure. It was a file left over from the previous installation when I installed python. When I was building the project, I didn't notice that I had selected the wrong one. It caused me to struggle for a long time. You can just delete the previous document directly.
Then create a new project:
Create a new project:
In addition: When building the project, be sure to check inherit globol site-packages so that the packages installed by pip can be used.