LoginSignup
26
16

More than 1 year has passed since last update.

急にpip installで一部のライブラリのインストールが失敗するようになった件

Posted at

はじめに

この記事は2021年9月6日以降に、
pipでのインストールで以下の様なエラーが出て困っている人に向けて書いています。
(私の場合、GDALのインストールが失敗するようになりました)

Collecting GDAL==2.2.3
  Using cached GDAL-2.2.3.tar.gz (475 kB)
    ERROR: Command errored out with exit status 1:

(~中略~)

    Complete output (5 lines):
    /usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'use_2to3_fixers'
      warnings.warn(msg)
    /usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'use_2to3_exclude_fixers'
      warnings.warn(msg)
    error in GDAL setup command: use_2to3 is invalid.
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/fb/62/e4c597c0b52bf0ddf7073c57e998c96cd98a8281a2cf40a8c036b34e4ec0/GDAL-2.2.3.tar.gz#sha256=561a952394bc1d9291179a8677eb6f5dafbf3e361c851f3dbb59db604c9b8e8b (from https://pypi.org/simple/gdal/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement GDAL==2.2.3 (from versions: 1.5.0, 1.5.2, 1.6.0, 1.6.1, 1.7.0, 1.7.1, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.11.0, 1.11.1, 1.11.2, 2.0.0, 2.0.1, 2.1.0, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.4.0, 2.4.2, 2.4.3, 2.4.4, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.1, 3.3.2)
ERROR: No matching distribution found for GDAL==2.2.3

サクッと結論

原因

GDALに限らず、
以下のようなエラーメッセージであれば、setuptoolsが原因である可能性が高いです。

error in 〇〇 setup command: use_2to3 is invalid.
(〇〇はインストール失敗したライブラリ名)

setuptoolsはv58.0.0以降、"use_2to3"が失敗するようになっています。
("2to3"はpython2系を3系に変換するやつらしい。詳しくは知らんけど。)

以下、setuptools公式ドキュメントにて
v58.0.0の説明欄に「"2to3"はもうサポートしないよ」と書かれています。

対応方法

v58.0.0より古いverにダウングレードすれば、解決します。

setuptoolsのverを下げたい場合は、pipで58.0.0より古いverを指定して
installすれば下げられます。

(以下は57.4.0を指定した例)
pip install setuptools==57.4.0

おわりに

twitterで調べた限りGDAL以外でも起きるようなのですが、
あまり情報が出回ってなさそうだったので、記事にしておきました。

ちなみに今回の解決に至ったのも、twitterで"use_2to3"について
呟いている方々がおられたおかげです。

twitterで色々情報出してくれるエンジニアの方々に
この場を借りてお礼申し上げます。

26
16
1

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
26
16