08 Pipenv和Python包管理 明希
Python的依赖管理及Pipenv @frostming 我是谁? • 研发效能·持续集成@Tencent • 从 2014 年开始用 Python,前测试,现开发 • 开源爱好者 • Pipenv 维护者之一 队长别开枪,是我! 目录 CONTENTS 为什么需要虚拟环境 为什么需要依赖管理 Pipenv 的简单使用 Python 包管理的未来 为什么需要虚拟环境 你是否遇到过这些问题: Python 版本 • 若找不到合适的版本,需要报告冲突 • Pipenv (piptools) • Poetry • 没了 可用工具 Pipenv 的简单使用 • 自动创建、管理虚拟环境,与项目绑定 • 依赖解析、锁定 • 新的requirements.txt规范,基于TOML格式 • 优美的命令行界面 Pipenv Demo Python 包管理的未来 Python 包管理的未来0 码力 | 24 页 | 1.24 MB | 1 年前3Flask入门教程
10 创建虚拟环境 虚拟环境是独立于 Python 全局环境的 Python 解释器环境,使用它的好处如下: 保持全局环境的干净 指定不同的依赖版本 方便记录和管理依赖 我们将使用 Pipenv 来创建和管理虚拟环境、以及在虚拟环境中安装和卸载依赖 包。它集成了 pip 和 virtualenv,可以替代这两个工具的惯常用法。另外,它还集 成了 Pipfile,它是新的依赖记录标准,使用 我们首先使用 pip 安装 Pipenv,Windows 系统使用下面的命令: $ pip install pipenv Linux 和 macOS 使用下面的命令: $ sudo -H pip install pipenv 使用 Pipenv 创建虚拟环境非常简单,使用 pipenv install 命令即可为当前项 目创建一个虚拟环境: $ pipenv install 这个命令执行的过程包含下面的行为: 创建虚拟环境后,我们可以使用 pipenv shell 命令来激活虚拟环境,如下所示 (执行 exit 可以退出虚拟环境): 第 1 章:准备工作 11 $ pipenv shell 注意 除了 pipenv install 命令和 Git 相关命令外,除非特别说明,本书后续的 所有命令均需要在激活虚拟环境后执行。如果你不想每次都激活虚拟环境,可以在 命令前添加 pipenv run 前缀,比如0 码力 | 127 页 | 7.62 MB | 1 年前3Django、Vue 和Element UI 前后端原理论述
接口进行数据传输和交互,从而实现一个完整的 Web 应用。 3 《51 测试天地》七十四 www.51testing.com 二、搭建流程 2.1 后端搭建流程 安装相关包->创建工程->后端依赖(pipenv)创建虚拟环境->后端服务配置启动->后 端创建子应用->后端 Rest Framework->数据库配置 简要说明: 安装相关包:在开始之前,首先需要安装 Python 和 pip,然后安装 命令来安装。 创建工程:使用 Django 的命令行工具创建 Django 项目,例如:django-admin startproject projectname。 后端依赖(pipenv)创建虚拟环境:建议使用 pipenv 来创建和管理虚拟环境,以便 隔离项目的依赖和环境。 后端服务配置启动:在虚拟环境下,通过 Django 的 manage.py 启动服务,例如:python manage 解释器和包 安装目录,这样可以避免不同项目之间的依赖冲突。每个虚拟环境只包含该项目所需的 依赖,使得项目可以在独立的环境中运行,而不受其他项目的影响。 确保依赖一致性:虚拟环境通常会配合使用 Pipenv 等工具来管理项目的依赖,这样 可以确保项目在不同环境中安装相同的依赖版本,从而避免由于依赖版本不一致而引发 的错误。 提高项目可移植性:将项目的依赖放在虚拟环境中,可以使得项目在不同的计算机0 码力 | 61 页 | 6.84 MB | 1 年前3Hyperledger Fabric 2.2.1 Documentation
wnload] Pipenv [https://docs.pipenv.org/en/latest/#install-pipenv-today] 3. For US English: cd $HOME/git git clone git@github.com:hyperledger/fabric.git cd fabric/docs pipenv install pipenv shell make clone git@github.com:hyperledger/fabric-docs-i18n.git cd fabric-docs-18n/docs/locale/ml_IN pipenv install pipenv shell make -e SPHINXOPTS="-D language='ml'" html The make command generates documentation documentation: Python 3.7 [https://wiki.python.org/moin/BeginnersGuide/Download] Pipenv [https://pipenv.readthedocs.io/en/latest/#install-pipenv-today] After you make your updates to the documentation source files0 码力 | 848 页 | 11.56 MB | 1 年前3Hyperledger Fabric 2.1 Documentation
wnload] Pipenv [https://docs.pipenv.org/en/latest/#install-pipenv-today] 3. For US English: cd $HOME/git git clone git@github.com:hyperledger/fabric.git cd fabric/docs pipenv install pipenv shell make clone git@github.com:hyperledger/fabric-docs-i18n.git cd fabric-docs-18n/docs/locale/ml_IN pipenv install pipenv shell make -e SPHINXOPTS="-D language='ml'" html The make command generates documentation documentation: Python 3.7 [https://wiki.python.org/moin/BeginnersGuide/Download] Pipenv [https://pipenv.readthedocs.io/en/latest/#install-pipenv-today] After you make your updates to the documentation source files0 码力 | 904 页 | 10.95 MB | 1 年前3Hyperledger Fabric 2.2.0 Documentation
[https://wiki.python.org/moin/BeginnersGuide/Download] Pipenv [https://docs.pipenv.org/en/latest/#install-pipenv-today] cd fabric/docs pipenv install pipenv shell make html This will generate all Fabric documentation documentation: Python 3.7 [https://wiki.python.org/moin/BeginnersGuide/Download] Pipenv [https://pipenv.readthedocs.io/en/latest/#install-pipenv-today] After you make your updates to the documentation source files generate a build that includes your changes by running the following commands: cd fabric/docs pipenv install pipenv shell make html This will generate all the html files in the docs/build/html folder. You0 码力 | 820 页 | 10.90 MB | 1 年前3Hyperledger Fabric 2.2.1 Documentation
depending on your OS: • Python 3.7 • Pipenv 3. For US English: cd $HOME/git git clone git@github.com:hyperledger/fabric.git cd fabric/docs pipenv install pipenv shell make html For Malayalam (for example): clone git@github.com:hyperledger/fabric-docs-i18n.git cd fabric-docs-18n/docs/locale/ml_IN pipenv install pipenv shell make -e SPHINXOPTS="-D language='ml'" html The make command generates documentation Python 3.7 • Pipenv After you make your updates to the documentation source files, you can generate a build that includes your changes by running the following commands: cd fabric/docs pipenv install pipenv0 码力 | 601 页 | 9.48 MB | 1 年前3Hyperledger Fabric 2.1 Documentation
depending on your OS: • Python 3.7 • Pipenv 3. For US English: cd $HOME/git git clone git@github.com:hyperledger/fabric.git cd fabric/docs pipenv install pipenv shell make html For Malayalam (for example): clone git@github.com:hyperledger/fabric-docs-i18n.git cd fabric-docs-18n/docs/locale/ml_IN pipenv install pipenv shell make -e SPHINXOPTS="-D language='ml'" html The make command generates documentation Python 3.7 • Pipenv After you make your updates to the documentation source files, you can generate a build that includes your changes by running the following commands: cd fabric/docs pipenv install pipenv0 码力 | 633 页 | 9.19 MB | 1 年前3Hyperledger Fabric 2.2.0 Documentation
Note: you may need to adjust depending on your OS. Prereqs: • Python 3.7 • Pipenv cd fabric/docs pipenv install pipenv shell make html This will generate all Fabric documentation html files in docs/build/html Python 3.7 • Pipenv After you make your updates to the documentation source files, you can generate a build that includes your changes by running the following commands: cd fabric/docs pipenv install pipenv0 码力 | 577 页 | 9.03 MB | 1 年前3The Python Handbook
To solve this, you use virtual environments. We'll use venv . Other tools work similarly, like pipenv . Create a virtual environment using python -m venv .venv in the folder where you want to start0 码力 | 93 页 | 7.31 MB | 1 年前3
共 48 条
- 1
- 2
- 3
- 4
- 5