pipenv 将 composer、bundler、npm、yarn、cargo 等比较方便的包管理工具添加到了python 语言中,可以
帮助我们自动的管理virtualenv ,同时可以方便的从pipefile 中添加或者移除包
pipenv 解决的问题
- 我们不用在独立的使用pip 以及virualenv ,他们已经可以一起工作了
- 使用requirements.txt 方式管理包是有问题的,因此pipenv 使用pipefile 以及pipefile.lock
- 提供便捷的依赖图(通过 pipenv graph)
- 可以高效的加载.env 文件,方便快发
一个基本使用
- 安装
brew install pipenv
- 初始化一个项目
python3 环境
pipenv --python 3.7
效果
Creating a virtualenv for this project…
Pipfile: /Users/dalong/mylearning/pipenv-project/Pipfile
Using /usr/local/bin/python3 (3.7.2) to create virtualenv…
⠧ Creating virtual environment...Using base prefix '/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/dalong/.local/share/virtualenvs/pipenv-project-iZJiWFj1/bin/python3.7
Also creating executable in /Users/dalong/.local/share/virtualenvs/pipenv-project-iZJiWFj1/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /usr/local/bin/python3
✔ Successfully created virtual environment!
Virtualenv location: /Users/dalong/.local/share/virtualenvs/pipenv-project-iZJiWFj1
Creating a Pipfile for this project…
- 添加依赖
tap-mysql
pipenv install tap-mysql
效果
Installing tap-mysql…
Adding tap-mysql to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (430178)!
Installing dependencies from Pipfile.lock (430178)…