Creating and Using your Requirements file for your Project

Save a list your project dependencies, to reinstall your app to other locations

Go Back

Preface

When moving your Django project to a live server, you'll find that it is necessary to move the libraries and other various dependencies of your project over. You can create a list of the various dependencies your project uses by creating a file called requirements.txt that goes into your project's directory.

*Note: This tutorial assumes your using Python 3, along with the pip3 package manager.

 

Creating requirements.txt

First, make sure your project's virtualenv is activated. Go to the root of your project and run the following:

. bin/activate

Now be sure to move into your project's folder (not the environment), and run the following to create your requirements.txt file:

pip3 freeze > requirements.txt

 The pip3 freeze method will gather the list of dependencies your Django project uses. > requirements.txt outputs the information into a text file.

 

Installing your dependencies

Now that your dependency list is created and you moved to another server, you can now begin the installation of your required dependencies. Please make sure your virtualenv is running and your in the same directory as your requirements.txt file, then enter the following:

pip3 install -r requirements.txt

Optionally if you have issues finding the packages, you can try the following:

pip3 install -r requirements.txt --no-index --find-links