1.pipenv的环境配置
1.安装pipenv
pip install -U pipenv
2.创建pipenv工程项目
- 【step1】 创建工程目录
- 【step2】 进入工程目录
- 【step3】 pipenv初始化工程
- 【step4】 给工程目录指定Python版本(ps:Python版本必须是系统安装过的)
#【step1】 创建工程目录
mkdir pytestDemo001
#【step2】 进入工程目录
cd pytestDemo001
#【step3】 pipenv初始化工程(ps:Python版本必须是系统安装过的)
pipenv install --python 3.7
#【step4】 给工程目录指定Python版本(ps:Python版本必须是系统安装过的)
#pipenv --python 3.7 这种也可以
pipenv --python 3.7.7
3.Pycharm的解释器关联pipenv项目
2.pipenv基本命令
分类 | 参数 | 备注 |
---|---|---|
【环境】创建 | pipenv install —python 3.7 | 【指定版本】创建python3.7的虚拟环境 前提 PC系统已安装配置相关Python版本 |
【环境】指定版本 | pipenv —python 3.7 | 初始化python3.7的项目 |
【环境】删除 | pipenv —rm | 删除当前项目的pipenv |
安装 | pipenv install requests | 安装requests库 |
pipenv install —dev requests | 安装开发包(requests) | |
基本 | pipenv —version | 查看版本号 |
pipenv shell | 进入“虚拟环境”[exit 退出] | |
pipenv list | 在“虚拟环境”查看list | |
pipenv —venv | 查看当前项目绑定的虚拟目录 | |
pipenv graph | 查看库的依赖关系 | |
运行 | pipenv run pip list | 【等效于:pipenv shell —> pipenv list】 |
pipenv run pip show pytest | 查看已安装pytest的相关包 | |
pip show requests | 查看requests的相关信息 |
3.团队共享
【ps】保证“新环境成员”的“项目文件”中存在Pipfile
- 【step1】 pipenv install 或 pipenv install —dev
- 【step2】 pipenv shell #[PS] 所有的运行等操作必须进入“pipenv虚拟环境”后执行
- 【step3】 pipenv run python xxx.py # 运行xxx.py