Generally, we install third-party packages of Python by executing the following commands in the terminal to install:
pip install 要安装的包名
After the installation is successful, it is found that there is still a problem of not being able to find the package in PyCharm. Why?
In short, PyCharm cannot find the path of the package installed by pip, such as the path of the package I pip
installed before matplotlib
:
pip show matplotlib
Shown as follows:
Name: matplotlib
Version: 3.1.2
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: PSF
Location: /Users/superfarr/anaconda3/lib/python3.6/site-packages
Requires: pyparsing, numpy, cycler, kiwisolver, python-dateutil
Required-by: jupyterthemes
As above, matplotlib
the path of the package is: /Users/superfarr/anaconda3/lib/python3.6/site-packages
if Anaconda
this software is installed on your computer , you will bring pip
this tool, otherwise you need to install it manually pip
, and these two installation pip
methods determine the pip
difference in the storage location of the third-party package of Python. :
- If it
Anaconda
comes with itpip
, it willpip
install thepython
package to the/Users/用户名/anaconda3/lib/python3.6/site-packages
following by default when using the installation package - If it is to manually installed
pip
, install the package in general ispython
under installation directorylib\site-packages\包名
under
PyCharm cannot find this path by itself, so it needs to be configured manually.
Of course, you can also directly File->setting->Python Interpreter
click the plus sign in PyCharm to search for the required package name to download, but this method is slower, and the market has problems with downloading errors.
Let's talk about how to configure
pip
the path installed in PyCharm
Click the bottom right corner to configure Python Interpreter (Python interpreter)
you will probably find more Python Interpreter, because if it is installed before Anaconda
will own an interpreter, Mac version of PyCharm also comes with Python Interpreter, and Anaconda
comes with pip
installation The package is under the Anaconda
path, so you need to find this path.
selectInterpreter Settings
Click the gear in the upper right corner and selectadd
You will find that there are many environments on the left. Here, select the first configuration environment, Existing environment, and then configure the path. If it is installed, generally ~/anaconda3/bin/python
, click OK.
Then look at the third-party package of the current project and find pip
the third-party package installed before All have