pipenv 应用
发表于:2022-04-03浏览:35次TAG: #pipenv
# 概述
pipenv 类似于Java上的maven、gradle,依赖包管理工具
# 安装
```
pip install pipenv
```
更新
```
pip install --user --upgrade pipenv
```
# 入门
配置文件类似Pipfile
```
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests-html = "*"
[dev-packages]
[requires]
python_version = "3.7"
```
运行install、update等命令的话,还会创建一个Pipfile.lock文件
* 安装包
```
pipenv install requests
```
> 安装指定版本的包
```
pipenv install requests==2.13.0
```
* 卸载包
```
pipenv uninstall requests
```
* 更新包
```
pipenv update --outdated
```
> 更新所有包
```
pipenv update
```
> 更新所有包
```
pipenv update <包名>
```
* 从requirements.txt导入
> 如果项目中有requirements.txt文件,pipenv会在安装的时候自动导入。如果需要导入其他位置的requirements.txt,可以用下面的命令:
```
pipenv install -r path/to/requirements.txt
```
* 导出requirements.txt
```
pipenv lock -r
```
* 指定Python版本
```
pipenv --python 3
pipenv --python 3.6
pipenv --python 2.7.14
```