6

I am new to Django.

Every time I install new library using pip, I have to run pip freeze -l > requirements.txt and sometimes I forget this ( and error happens at my production environment).

What's the best way to run this command automatically when I install new packages...?

I am using:

Django==1.11.5 
Python 3.6.1
Astik Anand
  • 12,757
  • 9
  • 41
  • 51
kansiho
  • 532
  • 4
  • 18
  • 1
    Have you considered using a shell script that already includes the `pip freeze` command after your library installation? You could pass the library name as a command-line argument to your custom script. – code_dredd Sep 26 '17 at 23:49

2 Answers2

4

For Python 3 use below to update requirements.txt file. ''' pip3 freeze > requirements.txt '''

Anupam Chaplot
  • 1,134
  • 1
  • 9
  • 22
-2

You need to write the script for that and set a cron job which will perform this action.

Not the same thing but a better one, you can have a look on, pipreqs

Astik Anand
  • 12,757
  • 9
  • 41
  • 51