日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

使用pipenv代替virtualenv管理python包

發布時間:2025/3/8 python 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用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的方式為例

# pip 離線下載 # pip install --download DIR -r requirements.txt mkdir pipenv pip install -d ~/pipenv/ pipenv# pip 離線安裝pipenv pip install --no-index --find-links=pipenv/ pipenv# 使用pipenv創建虛擬環境 mkdir win_ansible cd win_ansible pipenv shell pip 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_profile pipenv shell# 虛擬環境會在當前用戶家目錄自動創建 test101@JQ/root#su - wangao Spawning 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.201 ansible ansible-cmdb pywinrm# 通過gitlab同步控制python包環境 git checkout develop git pull origin develop pip install -r requirements.txt -U復制代碼

推薦參考的文章

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/

總結

以上是生活随笔為你收集整理的使用pipenv代替virtualenv管理python包的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。