使用pipenv代替virtualenv管理python包
前言
第一次接触到 pipenv 是因为看到@董明伟大神的《使用pipenv管理你的项目》,之前可能和大家的选择类似使用 virtualenv 或者 pyenv 来管理 python 的包环境。virtualenv 是针对python的包的多版本管理,通过将python包安装到一个模块来作为python的包虚拟环境,通过切换目录来实现不同包环境间的切换。pyenv 是针对 python 版本的管理,通过修改环境变量的方式实现;虽然我自己对pipenv的掌握程度还不深,但是我自己能感受到更加简单而清晰的python包管理方式,并且pipenv还是Python官方正式推荐的python包管理工具。原文如下:
Pipenv — the officially recommended Python packaging tool from Python.org, free (as in freedom).
Pipenv 官方推荐的 Python 包管理工具
更新历史
2017年04月25日 - 初稿
阅读原文 - https://wsgzao.github.io/post/pipenv/
扩展阅读
Pipenv - https://docs.pipenv.org/
Pipenv & 虚拟环境 - http://pythonguidecn.readthedocs.io/zh/latest/dev/virtualenvs.html
推荐阅读
使用pipenv管理你的项目 @董伟明
http://www.dongwm.com/archives/%E4%BD%BF%E7%94%A8pipenv%E7%AE%A1%E7%90%86%E4%BD%A0%E7%9A%84%E9%A1%B9%E7%9B%AE/
【 python 基础系列 】 - pipenv 试用过程分享
http://pylixm.cc/posts/2018-01-13-python-pipenv.html
Pipenv 官方简介
Pipenv: Python Development Workflow for Humans
Pipenv — the officially recommended Python packaging tool from Python.org, free (as in freedom).
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world. Windows is a first–class citizen, in our world.
It automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile as you install/uninstall packages. It also generates the ever–important Pipfile.lock, which is used to produce deterministic builds.
The problems that Pipenv seeks to solve are multi-faceted:
You no longer need to use pip
and virtualenv
separately. They work together.
Managing a requirements.txt
file can be problematic, so Pipenv uses the upcoming Pipfile
and Pipfile.lock
instead, which is superior for basic use cases.
Hashes are used everywhere, always. Security. Automatically expose security vulnerabilities.
Give you insight into your dependency graph (e.g. $ pipenv graph
).
Streamline development workflow by loading .env
files.
Pipenv 安装和使用
我的使用深度不高,就以目前我实际使用pipenv的方式为例
1 | # pip 离线下载 |
推荐参考的文章
Python 2.6 升级至 Python 2.7 的实践心得 - https://wsgzao.github.io/post/python-2-6-update-to-2-7/
使用pypiserver快速搭建内网离线pypi仓库实践 - https://wsgzao.github.io/post/pypiserver/
RHEL7/CentOS7在线和离线安装GitLab配置使用实践 - https://wsgzao.github.io/post/gitlab/