0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Poetryでaddする際に--index-urlを指定したい場合

Last updated at Posted at 2025-07-23

概要

パッケージのサンプルなどでpackageのソース(--index-url)が記載されている場合poetryでどのようにするかをよく忘れるのでまとめました。

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

poetryでpackageソースを指定

poetry docs: Explicit Package Sources

以下の手順でソース元からパッケージをインストールすることが可能。

poetryのプロジェクトにソース情報を登録

poetry source add <source name> <source url>

# 例: pytorch (優先度付けないと他のパッケージもこのソース元をデフォルトで参照してしまう)
poetry source add pytorch-gpu-src https://download.pytorch.org/whl/cu118

# 例: paddleocr(優先度をつけた例)
poetry source add --priority=explicit paddle-gpu-src https://www.paddlepaddle.org.cn/packages/stable/cu118/

上記の結果、pyproject.toml[[tool.poetry.source]]に情報が追加されている

source元を指定しパッケージをインストール

poetry add <package name> --source <source name>

# 例:pytorch
poetry add torch torchvision torchaudio --source pytorch-gpu-src

# 例:paddleocr
poetry add paddlepaddle-gpu@3.0.0 --source paddle-gpu-src

# 例:ソース元に優先度付けないと他のパッケージで参照しめんどくさい。
poetry add ipykernel
Skipping virtualenv creation, as specified in config file.
Source (pytorch-gpu-src): Authorization error accessing https://download.pytorch.org/whl/cu118/ipykernel/

Could not find a matching version of package ipykernel

以上です。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?