Poetry下载安装(20230221最新方法)

引用一下官方介绍:

Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution.

翻译:Poetry是Python中用于依赖管理和打包的工具。它允许您声明项目所依赖的库,并将为您管理(安装/更新)它们。Poetry提供了一个锁定文件,以确保可重复安装,并可以构建用于分发的项目。

Poetry官方安装说明

一、下载并安装

刚开始安装的时候,看了网上的各种帖子,但是都没有安装成功,一直报404: Not Found,如果是这样,那么恭喜你,装错了。

看到这篇文章(https://www.cnblogs.com/tugeler/p/16857124.html)我才发现官方已经更改了安装地址,请看:

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的下载路径,以上为ubuntu示例,并提示需要进行配置环境变量等操作。

ps:安装路径可以自行更换,时间问题不做赘述(懒和菜是原罪),官方网站会有讲解。

二、配置环境变量

进入环境配置文件,可能提示“Command ‘vim’ not found, but can be installed with:”,是因为系统默认只有vi,没有vim,安装一下就好。

vim ~/.bashrc

将以下语句加入(按i进行文本插入)最后,并保存退出(:wq)。

export PATH="/home/scenery-ubuntu/.local/bin:$PATH"

最后在终端输入以下语句,运行 .bashrc文件中的脚本,使立即生效。

source ~/.bashrc

验证是否安装成功

poetry --version

如图,即为安装成功!

补充一个坑:安装Poetry的时候,按照官方说法需要保证自己的python版本为3.7及以上,很重要!

Poetry requires Python 3.7+. It is multi-platform and the goal is to make it work equally well on Linux, macOS and Windows.(官方提示)

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年8月8日
下一篇 2023年8月8日

相关推荐