Summary of python problems - pycharm cannot find the installed library

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
Insert image description here
, but the installed library cannot be found in pycharm. For example, as shown below:
Insert image description here
Check the installed library and find that it is not the same as the library installed on the C drive.
Insert image description here
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:
Insert image description here
Find the corresponding location in the C drive, and you can also see the location of the python interpreter:
Insert image description here
Insert image description here

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.
Insert image description here
Click Add interpreter and then add the location corresponding to the previous C drive. There are two options at this time.
Insert image description here
Select the other one to display many installed packages:
Insert image description here
Then select it to achieve:
Insert image description here
no errors will appear at this time.

Then I went to look at the time and date of the first corresponding python.exe
Insert image description here
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:

Insert image description here
Create a new project:
Insert image description here

In addition: When building the project, be sure to check inherit globol site-packages so that the packages installed by pip can be used.

Guess you like

Origin blog.csdn.net/qq_44772972/article/details/131856165