Python Poetry 依赖管理工具

本文介绍了Python的依赖管理工具Poetry,包括安装、配置、新建项目、使用PyCharm打开项目、添加与管理依赖、Poetry命令列表等。特别强调了Poetry如何通过分组管理运行时、测试和开发依赖,以及如何处理可选依赖和使用不同源。
摘要由CSDN通过智能技术生成

Python 依赖管理工具 poetry

安装

Linux, macOS, Windows (WSL)

curl -sSL https://install.python-poetry.org | python3 -

Windows (Powershell)

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py

配置

使用 poetry config --list 来查看配置

PS C:\Users\lingh\Desktop\poetry-demo> poetry config --list
cache-dir = "C:\\Users\\lingh\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
repositories.tsinghua.url = "https://pypi.tuna.tsinghua.edu.cn/simple"
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\lingh\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
PS C:\Users\lingh\Desktop\poetry-demo>

默认 poetry 会在 {cache-dir}\virtualenvs 创建虚拟环境,可以修改为创建在每个项目的目录下

PS C:\Users\lingh\Desktop\poetry-demo> poetry config virtualenvs.in-project true
PS C:\Users\lingh\Desktop\poe
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值