Home >Backend Development >Python Tutorial >Detailed explanation of requirements.txt in python
Introduction
The Python project must contain a requirements.txt file to record all dependent packages and their precise version numbers. for deployment in new environments.
The main writing methods are as follows
pip freeze > requirements.txt # 生成requirements.txt pip install -r requirements.txt # 从requirements.txt安装依赖
Supported writing methods
-r base.txt # base.txt下面的所有包 pypinyin==0.12.0 # 指定版本(最日常的写法) django-querycount>=0.5.0 # 大于某个版本 django-debug-toolbar>=1.3.1,<=1.3.3 # 版本范围 ipython # 默认(存在不替换,不存在安装最新版)
Third-party tool generation
pip freeze will come with some unnecessary packages, as well as packages that some packages depend on~
pipreqs automatically analyzes packages referenced in the project. When automatically building the Django project, the Mysql package was ignored, and the version was also very strange; and when searching online, an error message jumped out when a 404 was encountered.