In Python, the installation of a third-party module is done through the Package management tool PIP.
Generally speaking Third-party libraries will be registered in the official Python pypi.python.org website, to install a third-party library, you must first know the name of the library, you can search on the official website or pypi, such as pillow name is called pillow, so the installation of Pillow command is:
Upgrade Pip First
Installing Pillow
With pillow, it's easy to handle pictures. Just look for a picture to generate a thumbnail image:
When we try to load a module, Python searches for the corresponding. py file under the specified path, and if it does not, it will get an error:
By default, the Python interpreter searches the current directory, all installed built-in modules, and third-party modules, and the search path is stored in the sys
variables of the module path
:
If we want to add our own search directory, there are two ways:
One is to modify directly sys.path
, add the directory to search:
This method is modified at run time and is invalidated after the run is finished.
The second method is to set the environment variable PYTHONPATH
, and the contents of the environment variable are automatically added to the module search path. Settings are similar to setting the PATH environment variable. Note that you only need to add your own search path, and Python's own search path will not be affected.
python-third-party modules