另一个包管理工具 Pipenv


Pipenv是 Python 著名的 requests 库作者 kennethreitz 实现的一个包管理工具,它可以为我们的项目自动创建和管理虚拟环境并非常方便地管理 Python 包,现在它也已经是 Python 官方推荐的包管理工具。

Pipenv 我们可以简单理解为 pip 和 virtualenv 的集合体,它可以为我们的项目自动创建和管理一个虚拟环境。

Pipenv 解决了以下问题:

  • 我们不需要再手动创建虚拟环境,Pipenv 会自动为我们创建,它会在某个特定的位置创建一个 virtualenv 环境,然后调用 pipenv shell 命令切换到虚拟环境。

  • 使用 requirements.txt 可能会导致一些问题,所以 Pipenv 使用 Pipfile 和 Pipfile.lock 来替代之,而且 Pipfile 如果不存在的话会自动创建,而且在安装、升级、移除依赖包的时候会自动更新 Pipfile 和 Pipfile.lock 文件。

  • 广泛使用 Hash 校验,保证安全性。

  • 可以更清晰地查看 Python 包及其关系,调用 pipenv graph 即可呈现,结果简单明了。

  • 可通过自动加载 .env读取环境变量,简化开发流程。

Pipenv

pipenv shell
pipenv install
# 从github下载源码
pipenv install -e git+https://github.com/alecalve/python-bitcoin-blockchain-parser#egg=blockchain_parser
pipenv install -e git+https://github.com/ethereum/pyethereum.git@develop#egg=pyethereum
pipenv install -e git+https://github.com/ethereum/[email protected]#egg=web3

pip3 install git+https://github.com/ethereum/pyrlp.git@master

常用命令

pipenv --venv
pipenv --three
pipenv --python 3.6

pipenv --py
pipenv --site-packages
pipenv install django
pipenv install pytest --dev
pipenv uninstall requests
pipenv uninstall --all
pipenv lock

参考:
https://www.jianshu.com/p/1441169b3dbe
https://zhuanlan.zhihu.com/p/32913361