pipreqs one-line command to get the requirements.txt of the current project

Why do you need pipreqs

requirements.txt is a necessary file for a qualified python project, library or software package, which covers the third-party libraries used by all projects and the corresponding version numbers. For users who have obtained requirements.txt, they pip install -r requirements.txtcan install all the required dependent libraries in one line without delay.

But for developers, writing requirements.txt may be a time-consuming and labor-intensive task. After all, you may remember the Python version number you are using, but it is impossible to remember all the corresponding version numbers of all the libraries used in your project. At this time, you can use an artifact pipreqs.


Installation and use

First install:

pip install pipreqs

pipreqsCan be executed as a module by the python interpreter. Open the root directory of the project for which you currently want the requirements.txt. Enter pipreqs ./and wait quietly.
insert image description here
If the above message is output, the generation is successful.

insert image description here


Precautions (see here if you fail to run)

pipreqsPrecautions when using :

  • Encoding problem: add parameters --encoding, my projects are all utf-8 encoded, so enterpipreqs ./ --encoding=utf-8
  • Network problem: pipreqsThe command seems to need to access PyPi to obtain the version number of the specified library or the dependencies involved, so please ensure that your computer can access PyPi when running the command (this will happen if you are not connected to the Internet or DNS pollution)

Guess you like

Origin blog.csdn.net/weixin_45576923/article/details/113785582
Recommended