1. Export all dependent packages
Enter the project path and execute the following command:
pip freeze > requirements.txt
Then you can see the generated "requirements.txt" file in the current directory. You can open it and take a look. You will find that there is a lot of package information. In fact, here is the relevant information of all packages in your current python environment. If we only need to export the dependency packages required by the current project, I can use another approach.
2. Export only the dependency packages of the project
pipreqs ./
By default, the "pipregs" plug-in is not installed, so the following error will be prompted:
Therefore, install it through the following command:
pip install pipreqs
Then execute it pipreqs ./
and you can export it.
If you already have it requirements.txt
and need to use it pipreqs --force ./
, you can export it successfully after a while.
You can open the requirements.txt file to view the dependencies.
3. Import dependency packages
pip install -r requirements.txt