pip installs the third-party library pycharm import module but fails and the default installation path of pip install is modified

Enter pip show target library in cmd

Such as pip show pymysql

Relevant information will be displayed, notice that this package is installed in the Location: d:\anaconda3\lib\site-packages directory,

Simple and rude solution, go to that directory and copy the relevant files to the \lib\site-packages directory of the target interpreter, such as C:\Users\ly\AppData\Local\Programs\Python\Python39\Lib\site -packages

Relevant files can be viewed through pip install target library (note: some third-party libraries may install multiple folders at one time, and all of them must be copied out!)

insert image description here

 

Possible situation 1:

The interpreter used by the pycharm project is the interpreter under the project instead of the system's python, so when installing with cmd pip, it will only be installed into the system's python

Solution 1: Continue to use the interpreter of the project and re-add the download in pycharm-file-setting-project-project interpreter

Solution 2: Replace the interpreter in the pycharm-file-setting-project-project interpreter and replace it with the system's python

Solution 3: If a new project is used in the project: the virtual environment is not required

For details, see: (17 messages) About pip installing third-party libraries, but PyCharm cannot recognize them; and analysis of the method of PyCharm installing third-party libraries Three-party library

Possibility 2:

Because anaconda is installed, it is downloaded to ~\Anaconda3\Lib\site-packages, enter python -m site in cmd and output USER_SITE: You can see the default pip installation path

Enter python -m site help to see that the path configuration is lib/site.pyconfigured in the ~/Anaconda3/ file in our installation directory! Then modify this file next!

  • USER_SITE = “”
  • USER_BASE = “”

USER_SITE indicates the storage path of the downloaded package, the default address is None, and it may be other
USER_BASE indicates the storage location of python.exe, pip.exe, and other scripts in a certain environment. The point is that there is a pip.exe folder, Therefore, it is better to add one more layer of \Scripts. If you do not add \Scripts, the following error may be reported (the second error). The first error is because the path name must be separated by \\ and you cannot use \ or /, which will turn meaning characters.

 

 After modification, enter python -m site help again to see that the default path has been changed

For detailed steps, see:

(17 messages) pip changes the installation path of the default package_Adslksf's Blog-CSDN Blog_pip changes the installation path

pip install default installation path modification - Diving Sunshine - Blog Garden (cnblogs.com)

 

 

Guess you like

Origin blog.csdn.net/m0_51711485/article/details/124119651