Use pip freeze> requirements.txt command to migrate the module under python

When we develop a project, we will use virtualenv to create a lot of python independent environments,

At this time, when the same module is installed in different environments, in order to prevent us from downloading the required modules through the Internet,

It is better for us to directly use it directly from the modules that already existed in the python environment.
At this time, you need to use the pip freeze command.

Specific use:

We open the cmd command window,

1) Enter pip freeze >requirements.txt and press Enter

At this time,
a text document named requirements.txt will be generated in my folder (C:\Users\Administrator)

2) We create an independent environment virtualenv myenv and then enter the Scripts folder of myenv, enter activate to activate the environment,

After activation, a sign enclosed in brackets will appear at the top of the command line, such as our (myenv).
At this time, we execute the command | pip install -r C:\Users\Administrator\requirements.txt
to automatically install it.

note:

C:\Users\Administrator\requirements.txt This is my path. You can replace it with yours wherever your requirements.txt is.

(If you use pip install ./requirements.txt directly in the project directory) install all the libraries that you need to rely on! ! !
The name (requirements.txt) can also be changed, as long as it is the same as the name before the module is collected and installed.
When I collected it, it was (requirements.txt), so the file I collected before (requirements.txt) was used when installing.

 

 

 

 

Guess you like

Origin blog.csdn.net/yang520java/article/details/107563484
Recommended