0%

pip usage

Pip Usage

pip 基本语法😉

1
2
3
pip install SomePackage            # latest version
pip install SomePackage==1.0.4 # specific version
pip install 'SomePackage>=1.0.4' # minimum version

pip 高级用法👍

编写 package 版本文件 requirements.txt (●’◡’●)

当前已装库 list

pip freeze 可以实现:获得项目运行时,所需安装库的固定版本

1
pip freeze > requirements.txt

运行该语句后,在项目目录会出现 requirements.txt 其中包含环境中的各种 package

安装语法🎶

pip install -r 将会自动安装 requirements.txt 中的所有 package

1
pip install -r requirements.txt

requirements.txt 结构

  • Comments:A line that begins with # is treated as a comment and ignored.

  • Encoding:Requirements files are utf-8 encoding by default

  • Line continuations(续行):A line ending in an unescaped \ is treated as a line continuation

requirements.txt 例

1
2
3
4
5
6
###### Requirements with Version Specifiers ######
# See https://www.python.org/dev/peps/pep-0440/#version-specifiers
docopt == 0.6.1 # Version Matching. Must be version 0.6.1
keyring >= 4.1.1 # Minimum version 4.1.1
coverage != 3.5 # Version Exclusion. Anything except version 3.5
Mopidy-Dirble ~= 1.1 # Compatible release. Same as >= 1.1, == 1.*

一个例子

Donate comment here.