博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用pipenv代替virtualenv管理python包
阅读量:7116 次
发布时间:2019-06-28

本文共 2764 字,大约阅读时间需要 9 分钟。

前言

第一次接触到 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日 - 初稿

阅读原文 -

扩展阅读

Pipenv -

Pipenv & 虚拟环境 -


推荐阅读

使用pipenv管理你的项目 @董伟明

【 python 基础系列 】 - pipenv 试用过程分享

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的方式为例
# pip 离线下载# pip install --download DIR -r requirements.txtmkdir pipenvpip install -d ~/pipenv/ pipenv# pip 离线安装pipenvpip install --no-index --find-links=pipenv/ pipenv# 使用pipenv创建虚拟环境mkdir win_ansiblecd win_ansiblepipenv shellpip install --no-index --find-links=pip-ansible-2.4.3.0/ -r requirements.txt# 升级ansible版本pip install --no-index --find-links=pip-ansible-2.5.0/ -r requirements.txt -U# 退出虚拟环境exit# 对不同开发用户自动创建python虚拟环境vim ~/.bash_profilepipenv shell# 虚拟环境会在当前用户家目录自动创建test101@JQ/root#su - wangaoSpawning environment shell (/bin/bash). Use 'exit' to leave.test101@JQ/home/wangao$. /home/wangao/.local/share/virtualenvs/wangao-iOSX51hl/bin/activate# 沿用pip创建requirements.txt,该方法相对Pipfile来说不是最佳(wangao-iOSX51hl) test101@JQ/home/wangao/git/ansible$cat requirements.txt --index-url=http://172.31.96.201:8081/simple/--trusted-host=172.31.96.201ansibleansible-cmdbpywinrm# 通过gitlab同步控制python包环境git checkout developgit pull origin developpip install -r requirements.txt -U

推荐参考的文章

Python 2.6 升级至 Python 2.7 的实践心得 -

使用pypiserver快速搭建内网离线pypi仓库实践 -
RHEL7/CentOS7在线和离线安装GitLab配置使用实践 -

转载地址:http://xubel.baihongyu.com/

你可能感兴趣的文章
深入分析JavaWeb Item8 -- HttpServletResponse常见应用
查看>>
Uber 开源深度学习分布训练库 Petastorm
查看>>
5G将如何影响物联网
查看>>
阿里云容器服务Kubernetes实践系列 - Ingress篇
查看>>
mysql审计
查看>>
Data Structure_Visualization
查看>>
浅谈IPsec的工作原理及优缺点
查看>>
利用java实现发送邮件
查看>>
python 模板中的语法
查看>>
JavaFX控件——FileChooser(文件选择框)
查看>>
视频直播网站开发千万不能忘的一个知识点
查看>>
Unity 3D中的射线与碰撞检测
查看>>
3月21日云栖精选夜读 | 重磅发布:阿里开源 OpenJDK 长期支持版本 Alibaba Dragonwell ...
查看>>
puppet确保程序运行
查看>>
Java spring boot 2.0连接mysql异常:The server time zone value 'Öйú±ê×¼Ê...
查看>>
Python爬虫入门教程 7-100 蜂鸟网图片爬取之二
查看>>
使用expo在安卓模拟器中运行React Native程序
查看>>
码农西游 | 写一本技术书可以赚多少钱
查看>>
最详细的Vue Hello World应用开发步骤
查看>>
标签打印软件如何制作三角形合格证
查看>>