python-third-party modules

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.