Today we bring the content is more practical, mainly for the zero foundation of small partners, without saying much, directly start code (the content of this article is in the first person)

I usually execute the PIP Install installed third-party libraries directly, as is the case in many tutorials, and I have always considered this to be the standard and correct way to install Python third-party libraries. Here is a tutorial to share with you, let’s have a look!

 

To summarize: The most correct installation is to use Python -m PIP to execute the PIP command, in any case

Here, I would like to make a few suggestions

  1. It is recommended to install the tripartite library with Python -m PIP
  2. Be sure to use a virtual environment and do not install Python on the system
  3. It is recommended to use the piPX independent installation tool
  4. It is recommended to create virtual environments using Python -m venv
  5. The container as a whole can be used as an environment, skipping the virtual environment

1. It is recommended to install the tripartite library using Python -m PIP

Rationale: Allows for more accurate control over where libraries are installed.

Many people will have several versions of Python installed on their computers at the same time. A few extreme users will even install different minor versions, such as 3.7 and 3.7.4. Using PIP directly, you might not even know which version of Python you ended up installing.

 

2. Use a virtual environment and do not install Python

This advice should be widely accepted and implemented in practice. If virtual environment isolation is not used, the system version of the third-party libraries will become particularly complex, and even the version of the system dependent libraries is not reasonable, resulting in a serious problem of system crash.

 

3. It is recommended to use the piPX independent installation tool

If you want to try out development tools such as Black and Mypy, consider using PIPX to install each of these tools in a separate environment, while also being able to directly access the terminal from the system environment.

 

4. It is recommended to create a virtual environment using Python -m venv

Brett personally preferred to use the Python -m venv command to create virtual environments for the same reason as suggested in the first point, which gives him more control over precisely which version to use.

 

5. You can treat the container as an entire environment, skipping the virtual environment

If the project is containerized, there is no problem using each container as a separate virtual environment. There is no need to create virtual environments separately in containers. That is, of course, if you don’t install it in Python.

Tail:

This is the correct way to install python libraries!!