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)...
?? ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 13/14 - 00:00:00
?? ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 14/14 - 00:00:03
- To activate this project's virtualenv, run pipenv shell.
- Alternatively, run a command inside the virtualenv with pipenv run.
运行安装的 tap
pipenv run tap-MySQL
依赖图
- pipenv graph
- tap-MySQL==1.10.0
- - attrs [required: ==16.3.0, installed: 16.3.0]
- - backoff [required: ==1.3.2, installed: 1.3.2]
- - MySQL-replication [required: ==0.18, installed: 0.18]
- - pymysql [required: Any, installed: 0.7.11]
- - pendulum [required: ==1.2.0, installed: 1.2.0]
- - python-dateutil [required: Any, installed: 2.7.5]
- - six [required:>=1.5, installed: 1.12.0]
- - pytzdata [required: Any, installed: 2018.7]
- - tzlocal [required: Any, installed: 1.5.1]
- - pytz [required: Any, installed: 2018.4]
- - PyMySQL [required: ==0.7.11, installed: 0.7.11]
- - singer-python [required: ==5.3.1, installed: 5.3.1]
- - backoff [required: ==1.3.2, installed: 1.3.2]
- - jsonschema [required: ==2.6.0, installed: 2.6.0]
- - python-dateutil [required:>=2.6.0, installed: 2.7.5]
- - six [required:>=1.5, installed: 1.12.0]
- - pytz [required: ==2018.4, installed: 2018.4]
- - simplejson [required: ==3.11.1, installed: 3.11.1]
说明
pipenv 工具还是很方便的, 帮助我们简化了好多实际开发中的问题, 在项目中很值得使用
参考资料
https://github.com/pypa/pipenv
来源: http://www.bubuko.com/infodetail-2944998.html