LoginSignup
4

More than 3 years have passed since last update.

pip install で "launchpadlib requires testresources, which is not installed." と表示された時の対処法

Posted at

Cloud Speech-to-Text API を使うために、必要なものをpipでインストールしようとした時に発生したエラーに対して、どのように対処したのかを書いてみた。

TL;DR

sudo apt install python3-testresources

バージョン

  • OS: Ubuntu 19.04
  • Python: 3.7.3
  • pip: 18.1

エラー発生状況

今回のエラーはpip install google-cloud-speechを実行した時に発生した。

$ pip install google-cloud-speech
(省略)
launchpadlib 1.10.6 requires testresources, which is not installed.
(省略)

どうやら、launchpadlibパッケージがtestresourcesを要求しているみたいだ。

ちなみに、このメッセージはpip checkで確認できる。

$ pip check
launchpadlib 1.10.6 requires testresources, which is not installed.

どのように対処したか

とりあえず、launchpadlibtestresourcesがあるのか確認してみると、testresourcesがマシン上にないことが判明した。

$ find / -name "*launchpadlib*" 2> /dev/null
/usr/share/doc/python3-launchpadlib
/usr/lib/python3/dist-packages/launchpadlib
/usr/lib/python3/dist-packages/launchpadlib-1.10.6.egg-info
/var/lib/dpkg/info/python3-launchpadlib.md5sums
/var/lib/dpkg/info/python3-launchpadlib.prerm
/var/lib/dpkg/info/python3-launchpadlib.postinst
/var/lib/dpkg/info/python3-launchpadlib.list
$ find / -name "*testresources*" 2> /dev/null

しかし、何をどうすれば良いのかわからないので、Google先生に聞いてみたところ、このページを教えてくれた。
同じような問題出くわす人は世界中にいるみたいだ。

例に従って、aptを使ってパッケージを検索してみた。

$ apt search testresources
python-testresources/disco,disco 2.0.0-2 all
  PyUnit extension for managing expensive test fixtures - Python 2.x

python3-testresources/disco,disco 2.0.0-2 all
  PyUnit extension for managing expensive test fixtures - Python 3.x

すると、Python 2.x 版と Python 3.x 版が引っかかった。
私の環境は Python 3.7.3 なので、後者の方をインストールした。
そうすると、無事にエラーが解消された。

$ sudo apt install python3-testresources
(省略)
$ pip check
No broken requirements found.

終わりに

泥沼にはまり込むようなエラーでなくてよかった。

編集後記

この記事を書き終わってから、他のQiita記事を見てみたけど、このエラーがスルーされている記事を見かけた。
そして実際にtestresourcesgoogle-cloud-speechをアンインストールして、google-cloud-speechを再インストールすることでこのエラーを再現してみた。

結論、別にtestresources必要ない。
名前から察するに、何かをテストするために必要なのかな。
ただ、私はこのパッケージについて詳しくないので、このエラーが出ていても問題ないとは言えない。。。
testresourcesがあれば、何かしらの脆弱性への対策に少しはなるのかな。

個人的にこういうエラーが残っているのは気持ち悪いので、testresourcesをインストールしておくことにする。
さて、再インストールだ。

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
4