Home >Backend Development >Python Tutorial >Detailed introduction to the entire contents of requirements.txt

Detailed introduction to the entire contents of requirements.txt

Y2J
Y2JOriginal
2017-05-05 17:25:231969browse

I have recently learned about requirements.txt in python. Perhaps it is because it is too simple and I have not found a more complete introduction on the Internet. Therefore, this article mainly introduces the relevant information about requirements.txt in python. Friends who need it can For reference, let’s take a look below.

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 referenced packages in the project. When automatically building the Django project, the Mysql package was ignored, and the version was also very strange; and when searching for on the Internet, it encountered a 404 error and jumped out.

The above is the detailed content of Detailed introduction to the entire contents of requirements.txt. For more information, please follow other related articles on the PHP Chinese website!

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