如何在Linux Mint上安装Python Poetry

984 阅读1分钟

1.概述

How to Install Python Poetry On Linux Mint

在这个简短的教程中,我们将介绍如何在Linux Mint或Ubuntu上安装Poetry。Poetry是一个用于Python打包的依赖性管理工具。

与pip类似,它允许你声明和项目库。作为奖励,它将为你安装和更新它们。

2.通过脚本在Linux Mint上安装Poetry

让我们首先通过脚本在Linux Mint上安装Poetry -get-poetry.py

安装的输出结果将是这样的。

Retrieving Poetry metadata

This installer is deprecated. Poetry versions installed using this script will not be able to use 'self update' command to upgrade to 1.2.0a1 or later.
# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

$HOME/.poetry/bin

This path will then be added to your `PATH` environment variable by
modifying the profile files located at:

$HOME/.profile
$HOME/.bash_profile

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing version: 1.1.12
  - Downloading poetry-1.1.12-linux.tar.gz (66.00MB)

Poetry (1.1.12) is installed now. Great!

To get started you need Poetry's bin directory ($HOME/.poetry/bin) in your `PATH`
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run `source $HOME/.poetry/env`

注意:如果你注意到一个警告,如。

这个安装程序已经过时了。使用这个脚本安装的Poetry版本将不能使用 "self update "命令升级到1.2.0a1或更高版本。

你可以简单地忽略它或检查这个问题:"此安装程序已被淘汰",并建议安装

3.通过PIP在Linux Mint上安装Poetry

作为一个替代方案,我们可以通过PIP安装Poetry。

由于Python已经预装在Linux Mint和Ubuntu上,如果需要,我们可以安装PIP。

sudo apt update
sudo apt install python3-pip

然后通过以下方式安装Poetry。

pip install --user poetry

**注意:**它将安装Poetry的依赖项,可能会与其他软件包产生冲突。

4.验证安装

为了验证安装情况,我们可以运行以下命令。

$HOME/.poetry/bin

这将导致类似的结果。

/home/van/.poetry/bin/poetry

5.更新Poetry

一旦Poetry安装完毕,要更新它,我们可以使用如下命令。

poetry self update

并检查已安装的版本,我们可以使用。

poetry --version

结果。

Poetry 1.1.12

如果你想更新到特定的版本,你可以使用下一个语法。

poetry self update 0.8.0

6.总结

在这篇文章中,我们看到了如何在Linux Mint上安装流行的软件包管理器Poetry。

它涵盖了如何验证安装,检查版本和更新它。