Python Basics 097: Export project dependent libraries | Environment dependent libraries | Automatically install all dependent libraries of the project

1. Export project dependent libraries

First open CMD, then cd to the folder where the project is located, and then use the following command to export the installed project dependency library:

pip freeze > requirements.txt

After execution, a file named requirements.txt will be generated in the project root directory, which contains the project dependent library and its version number (according to this file, you can directly install all dependent libraries with one command, which will be mentioned later)

2. Export environment dependent libraries:

Open CMD and use the following command to export the installed dependent libraries (including Python interpreter and all packages) in the entire environment:

pip freeze > environment.txt

A file named environment.txt will be generated in the current directory, which contains all installed dependent libraries and their version numbers.

3. Automatically install all dependent libraries

The requirements.txt file, which records all the dependent packages of the current program and their precise version numbers, is used to rebuild the runtime environment dependencies required by the project on another PC.

All dependent libraries can be automatically installed with the following command:

pip install -r requirements.

Guess you like

Origin blog.csdn.net/PoGeN1/article/details/131818069