LoginSignup
2
0

[Python3 / poetry] LinuxOS上にpoetryをinstallする方法が切り替わっていた

Last updated at Posted at 2022-12-16

記事の概要

以下の記事に従ってinstallしようとしたところ、エラーが発生してinstallできなかった。

そこで、その対策を記載した。

エラーの状況

記事に記載されているpoetryのinstall方法は古く(deprecatedに)なっているようでした。

$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
Retrieving Poetry metadata

This installer is deprecated, and scheduled for removal from the Poetry repository on or after January 1, 2023.
See https://github.com/python-poetry/poetry/issues/6377 for details.

You should migrate to https://install.python-poetry.org instead, which supports all versions of Poetry, and allows for `self update` of versions 1.1.7 or newer.
Instructions are available at https://python-poetry.org/docs/#installation.

Without an explicit version, this installer will attempt to install the latest version of Poetry.
This installer cannot install Poetry 1.2.0a1 or newer (and installs will be unable to `self update` to 1.2.0a1 or newer).

To continue to use this deprecated installer, you must specify an explicit version with --version <version> or POETRY_VERSION=<version>.
Alternatively, if you wish to force this deprecated installer to use the latest installable release, set GET_POETRY_IGNORE_DEPRECATION=1.

Version 1.3.1 is not supported by this installer! Please specify a version prior to 1.2.0a1 to continue!

対策

エラー出力の中に記載されている、

Instructions are available at https://python-poetry.org/docs/#installation.

という案内に従って https://python-poetry.org/docs/#installation にアクセスすると、

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

というinstallコマンドが記載されており、これに従うと、以下の通り無事にinstallできました。

$ curl -sSL https://install.python-poetry.org | python3 -
Retrieving Poetry metadata

# 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/ec2-user/.local/bin

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

Installing Poetry (1.3.1): Done

Poetry (1.3.1) is installed now. Great!

To get started you need Poetry's bin directory (/home/ec2-user/.local/bin) in your `PATH`
environment variable.

Add `export PATH="/home/ec2-user/.local/bin:$PATH"` to your shell configuration file.

Alternatively, you can call Poetry explicitly with `/home/ec2-user/.local/bin/poetry`.

You can test that everything is set up by executing:

`poetry --version`

このままだと poetry へのpathが通っていないので、通す必要があります。

# poetryへのpathが通っていないので、poetryコマンドがエラーになる
$ poetry --version
sh: poetry: command not found

# そこで、案内文に従ってpathを通す
# ******
# 通すpathはその人の環境によって違うので、
# 以下の通りには実行しないように注意
# ******
$ export PATH="/home/ec2-user/.local/bin:$PATH"

$ poetry --version
Poetry (version 1.3.1)

export PATH="/home/ec2-user/.local/bin:$PATH"は、~/.bashrc~/.bash_profile などに書いておくと、OSを再起動したときも自動で反映されていいですね。

**** 注意 ****

大事なのでもう一回注意ですが、 /home/ec2-user/.local/bin:$PATH" という部分はその人の環境によって違うので curl -sSL https://install.python-poetry.org | python3 - 実行後の出力をよく読んで、自分に必要なpathを設定してください!

補足

poetry installなどを実行した際に、以下のようなエラーが出ることがある。

エラー文
/home/username/.../app_name does not contain any element

このときは、以下のissueに従って--no-rootを付けたら解決した。

こんな感じ

bash
poetry install --no-root
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0