pipenv 方便的python 开发工作流工具
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://www.kennethreitz.org/essays/a-better-pip-workflow
https://github.com/pypa/pipenv
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2016-02-04 Mozilla Brick:一个Web组件Polyfill库
2016-02-04 可选的Web Components类库