LoginSignup
9
5

More than 5 years have passed since last update.

DistributionNotFoundと言われた時のpip, distribute更新の注意点

Posted at

DistributionNotFoundエラーの対処方法という記事にもあるように、pipを用いたpythonパッケージのインストールで次のようなエラーが返ってくることがある。

Traceback (most recent call last):

:  :  :  :  :  

  File "c:\python27\lib\site-packages\distribute-(バージョン)-py2.7.egg\pkg_resources.py", line 2655, in <module>
    working_set.require(__requires__)
  File "c:\python27\lib\site-packages\distribute-(バージョン)-py2.7.egg\pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "c:\python27\lib\site-packages\distribute-(バージョン)-py2.7.egg\pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: (見つからないパッケージ名)

エラーを見てみるに、distributeパッケージ(?)で欲しいパッケージが登録されていない、みたいな感じだと読み取れる。

上記の記事では、pip自体をupgradeして解決しているが、自分の場合は解決しなかった。
つまり、最新版のpipをインストールしているのにダメだった。

ただ、よくよく調べてみると(例えばこの記事)、setuptoolsというパッケージがより上位にあり、これを最新版としないとpipやdistributeが最新版とならない。これで自分のケースは解決。

結論として、まず、上のエラー文にあるようなバージョンを確認する(←他のエラー時もバージョン情報により注意を向ける癖をつけるべきと感じた)。
それが、最新じゃなさそうな(同じパッケージ名でググってなんかもっと新しいバージョンのやつがある)とき、インストール関連のパッケージの更新を試みる。
その際、まずはsetuptoolsを更新。

pip install --upgrade setuptools

そして、distributeやpipを更新。

pip install --upgrade distribute
pip install --upgrade pip
9
5
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
9
5