Python - handle package dependencies with requirements.txt

To create same environment in python, you must know requirements.txt, it includes packages dependencies and let you install by a single command, a requirements.txt looks like this :

1
2
3
beautifulsoup4==4.6.0
certifi==2018.1.18
chardet==3.0.4

To generate requirements.txt

1
2
3
4
5
6
# Without using virtual environment
pip install pipreqs
pipreqs /path/to/project

# With virtual environment
pip freeze > requirements.txt

Install packages from requirements.txt :

1
pip install -r requirements.txt

pip install bypass SSL certificate :

1
2
3
4
pip install --trusted-host pypi.python.org <package_name>

# Combine with requirements.txt
pip install --trusted-host pypi.python.org -r requirements.txt

Reference

https://github.com/bndr/pipreqs
pip install --help is your friend.