SoFunction
Updated on 2024-11-13

Summary of several methods of python exporting

Several methods for python exports

Common Methods:

1. pip freezen >

Possible paths in exported results

2. pip list --format=freeze >

Export without path

Note: Generate, pip freeze will generate all the installation packages under the current PC environment, and then when installing it will install many packages that are not available. This method should be noted.

3. Export in conda

Way one,

  • a. Export
conda list -e > 
  • b. Import Installation
conda install --yes --file 

Way two,

  • c. Export yml file method
conda env export > 
  • d. Installation
conda env create -f 

4. pipreqs export

Use pipreqs, a tool that has the benefit of scanning the project directory to find out which libraries are used, generating a list of dependencies.

  • step1: install pipreqs (not installed by default)
pip install pipreqs
  • step2: export using pipreqs

In the root directory of the python project use pipreqs . /

Python projects automatically export and import requirement dependencies

Automatic file export

1、Installation of packaging library

pip install pipreqs

2. Generate files in the current directory

pipreqs ./ --encoding=utf-8 --force

[-force enforces overwriting of the generated directory when it exists].

Auto Import

1. Import and install dependencies

pip install -r 

summarize

The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.