#vscode | poetry # 使用Poetry进行项目依赖自动化管理,比pip更省事!

本文详细介绍了如何在Linux和Windows系统上安装Poetry,设置虚拟环境,使用VSCode配置,以及管理项目依赖。步骤包括验证安装、迁移项目、初始化新项目和安装依赖等。
摘要由CSDN通过智能技术生成

安装poetry

系统安装poetry

Linux:
curl -sSL https://install.python-poetry.org | python3 - 安装
Windows:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
在这里插入图片描述poetry --version 验证安装是否成功
在这里插入图片描述

迁移poetry项目

项目安装poetry

poetry env use python3.11 设置虚拟环境
poetry install install 命令从当前项目中读取 pyproject.toml 文件,解析依赖项并安装它们。
在这里插入图片描述

Vscode配置 对应虚拟环境的interpreter

terminal输入poetry shell,得到poetry的路径

. /home/用户名/.cache/pypoetry/virtualenvs/rag-utils-re8bqiF8-py3.11/bin/activate

interpreter配置编译器位置:

. /home/用户名/.cache/pypoetry/virtualenvs/rag-utils-re8bqiF8-py3.11/bin/你的python版本

安装依赖

poetry install

初始化poetry项目

poetry init
在这里插入图片描述
你会发现目录中生成了pyproject.toml文件
在这里插入图片描述

poetry install
在这里插入图片描述

你会发现目录中生成了poetry.lock文件在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值