Install python extension library

Blogger: Light of Destiny

Column: Python Programming

Python extension library installation

Python provides a rich standard library (no installation required), and also supports a large number of third-party extension libraries . They are numerous, powerful, wide-ranging, and easy to use, and are favored by engineers in various industries. Therefore, proficient use of Python extension libraries can improve software development speed.

What are modules, libraries, and packages?

Generally speaking, a module is a Python source program file, and a library/package is a folder that contains several modules and has a file named __init__.py. For a single module that contains complete functional code, it can also be called a library, but libraries are generally not called modules.

The pip tool that comes with Python is the main way to manage extension libraries and supports operations such as installation, upgrade, and uninstallation of Python extension libraries. The pip command needs to be executed in a command prompt environment. Installing the extension library requires the computer to remain online/

The default installation source location of Python's pip is overseas ( PyPI · The Python Package Index ), resulting in sometimes slow downloading or direct failure. We can switch domestic sources:

Douban: https://pypi.doubanio.com/simple/

University of Science and Technology of China: Simple Index

pip install -i domestic source URL packagename

Extension: How to permanently replace pip installation source?

%APPDATA% \pip\pip.ini (New)

pip config set global.index-url https://pypi.doubanio.com/simple/

Using the pip command to manage Python extension libraries needs to be done in a command prompt environment, and you need to switch to the directory where pip is located.

Enter the scripts folder in the Python installation folder, hold down the Shift key, right-click the blank space, and select "Open command window here" to directly enter the command prompt environment.

It is recommended to upgrade pip to the latest version when using it for the first time: python-m pip install --upgrade pip

Notice:

  • There may be mutual dependencies between extension libraries
  • Upgrading an extension library may cause the related extension library to be unusable. Pay attention to the requirements between versions. Some extension libraries may require a VC environment for compilation.
  • It is recommended to use domestic mirror sources
  • The file name of the installed extension library is not necessarily the same as the library/module name [opencv-python--->cv2]

Guess you like

Origin blog.csdn.net/VLOKL/article/details/133417946