Requirements File

Requirements File#

A pip requirements file is a text file, named requirements.txt, that contains a list of Python packages needed to run science notebooks. When users download a science notebook, they need this requirements file to install the necessary Python packages. Therefore, Notebook Leads will need to provide a requirements file in addition to their notebooks.

Listing Packages: Each Python package should be listed in a new line in the requirements file. You should only list packages imported into your notebook (used in your notebook). You can make a list of packages by looking though import statements in your notebook. Packages that are native to Python, such as os or math, should not be listed in the requirements file.


You can get a list of package versions by running conda list or pip list in your terminal.

To specify a version of the package, you can use the == operator (for example astropy==4.1). Please list all requirement versions to match the conda or pip environment you used to develop your notebooks. If you need to add a Python package only available on GitHub, you can list the module as follows:

# Package on GitHub:

# If you need to specify a branch:

Example: Here is an example requirements file (requirements.txt):



To install packages in a requirements.txt file, use pip install -r requirements.txt


Before installing a new set of packages from a requirements file, one should consider creating a new Conda environment. If you need to setup Conda, please see the Conda’s Getting Started documentation.

Sometimes, the dev team adds an extra requirement file named pre-requirements.txt. This file is used for the testing infrastructure and should be installed before the requirements.txt. The notebook lead is not expected to contribute the pre-requirements.txt file.