Home  >  Article  >  Backend Development  >  Detailed explanation of requirements.txt in python

Detailed explanation of requirements.txt in python

高洛峰
高洛峰Original
2017-03-06 11:41:571896browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn