pip install cdqaでエラーが出たときの解決法

環境はUbuntu18.04です。Pythonは3.8.11を3.6.10に変更しました。(詳細は下で書いています)

実行したコマンドとエラー内容

まずは

pip install cdqa

とすると、

Collecting cdqa
  Using cached cdqa-1.3.9.tar.gz (45 kB)
Requirement already satisfied: Flask==1.1.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa) (1.1.1)
Using cached Flask_Cors-3.0.8-py2.py3-none-any.whl (14 kB)
Requirement already satisfied: joblib==0.13.2 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa) (0.13.2)
Collecting pandas==0.25.0
  Using cached pandas-0.25.0.tar.gz (12.6 MB)
Collecting prettytable==0.7.2
  Using cached prettytable-0.7.2-py3-none-any.whl
Collecting transformers==2.1.1
  Using cached transformers-2.1.1-py3-none-any.whl (311 kB)
Collecting scikit_learn==0.21.2
  Using cached scikit-learn-0.21.2.tar.gz (12.2 MB)
Requirement already satisfied: tika==1.19 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa) (1.19)
Collecting cdqa
  Using cached cdqa-1.3.8.tar.gz (45 kB)
  Using cached cdqa-1.3.7-py3-none-any.whl
Requirement already satisfied: tqdm==4.32.2 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa) (4.32.2)
Collecting markdown==3.1.1
  Using cached Markdown-3.1.1-py2.py3-none-any.whl (87 kB)
Requirement already satisfied: torch>=1.2.0 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa) (1.9.0)
Requirement already satisfied: wget==3.2 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa) (3.2)
Requirement already satisfied: transformers>=2.1.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa) (4.9.0.dev0)
Requirement already satisfied: click>=5.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from Flask==1.1.1->cdqa) (8.0.1)
Requirement already satisfied: itsdangerous>=0.24 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from Flask==1.1.1->cdqa) (2.0.1)
Requirement already satisfied: Jinja2>=2.10.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from Flask==1.1.1->cdqa) (3.0.1)
Requirement already satisfied: Werkzeug>=0.15 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from Flask==1.1.1->cdqa) (2.0.1)
Requirement already satisfied: Six in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from flask_cors==3.0.8->cdqa) (1.15.0)
Requirement already satisfied: setuptools>=36 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from markdown==3.1.1->cdqa) (56.0.0)
Requirement already satisfied: python-dateutil>=2.6.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from pandas==0.25.0->cdqa) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from pandas==0.25.0->cdqa) (2021.1)
Requirement already satisfied: numpy>=1.13.3 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from pandas==0.25.0->cdqa) (1.19.5)
Requirement already satisfied: scipy>=0.17.0 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from scikit_learn==0.21.2->cdqa) (1.7.0)
Requirement already satisfied: requests in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from tika==1.19->cdqa) (2.25.1)
Requirement already satisfied: MarkupSafe>=2.0 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from Jinja2>=2.10.1->Flask==1.1.1->cdqa) (2.0.1)
Requirement already satisfied: typing-extensions in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from torch>=1.2.0->cdqa) (3.7.4.3)
Requirement already satisfied: pyyaml>=5.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from transformers>=2.1.1->cdqa) (5.4.1)
Requirement already satisfied: sacremoses in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from transformers>=2.1.1->cdqa) (0.0.45)
Requirement already satisfied: packaging in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from transformers>=2.1.1->cdqa) (21.0)
Requirement already satisfied: filelock in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from transformers>=2.1.1->cdqa) (3.0.12)
Requirement already satisfied: regex!=2019.12.17 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from transformers>=2.1.1->cdqa) (2021.7.6)
Requirement already satisfied: huggingface-hub==0.0.12 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from transformers>=2.1.1->cdqa) (0.0.12)
Requirement already satisfied: tokenizers<0.11,>=0.10.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from transformers>=2.1.1->cdqa) (0.10.3)
Requirement already satisfied: pyparsing>=2.0.2 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from packaging->transformers>=2.1.1->cdqa) (2.4.7)
Requirement already satisfied: certifi>=2017.4.17 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from requests->tika==1.19->cdqa) (2021.5.30)
Requirement already satisfied: chardet<5,>=3.0.2 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from requests->tika==1.19->cdqa) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from requests->tika==1.19->cdqa) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from requests->tika==1.19->cdqa) (1.26.6)
Building wheels for collected packages: pandas, scikit-learn
  Building wheel for pandas (setup.py): started

のようなエラーが出ました。次に、cdqaは1.3.9が最新のようなので、以下のコマンドを実行しました。

pip install cdqa==1.3.9

とすると、

Collecting cdqa==1.3.9
  Using cached cdqa-1.3.9.tar.gz (45 kB)
Requirement already satisfied: Flask==1.1.1 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa==1.3.9) (1.1.1)
Collecting flask_cors==3.0.8
  Using cached Flask_Cors-3.0.8-py2.py3-none-any.whl (14 kB)
Requirement already satisfied: joblib==0.13.2 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa==1.3.9) (0.13.2)
Collecting pandas==0.25.0
  Using cached pandas-0.25.0.tar.gz (12.6 MB)
Collecting prettytable==0.7.2
  Using cached prettytable-0.7.2-py3-none-any.whl
Collecting transformers==2.1.1
  Using cached transformers-2.1.1-py3-none-any.whl (311 kB)
Collecting scikit_learn==0.21.2
  Using cached scikit-learn-0.21.2.tar.gz (12.2 MB)
Requirement already satisfied: tika==1.19 in ./.pyenv/versions/3.8.11/lib/python3.8/site-packages (from cdqa==1.3.9) (1.19)
ERROR: Could not find a version that satisfies the requirement torch==1.2.0 (from cdqa) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0)
ERROR: No matching distribution found for torch==1.2.0

のようにtorch==1.2.0をインストールしてくださいというメッセージが出ました。これにしたがって

pip install torch==1.2.0

とすると、

ERROR: Could not find a version that satisfies the requirement torch==1.2.0 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0)
ERROR: No matching distribution found for torch==1.2.0

というエラーが出ました。これは、私の今使っている環境がPython3.8.11を入れており、Python3.8ではtorch==1.2.0はもはや対応していないということを意味します。

解決できた方法

以下では、今回のエラーを解決し、pip

Python3.8ではダメだったので3.6を入れてみる

まず、なんとなくPython3.6ならtorch==1.2.0に対応しているかなと思い、自分の環境はpyenvを使用しているため

pyenv install 3.6.10

でpython3.6.10を入れてみました。(ここは3.6.1でも3.6.5でも、どれでもいいと思いますが、なんとなく後の方がエラーが解消されてるかと思い後ろの方のバージョンをいつも入れています)

pyenv global 3.6.10

とし、無事Python3.6に変更することに成功。

PyTorchのバージョン1.2.0を入れる

一応PyTorchの公式ページを見ると、

pip install torch==1.2.0 torchvision==0.4.0

と書いてあったので、このコマンドでtorchvisionも一緒にインストールすることにしました。すると、

Collecting torch==1.2.0
  Downloading https://files.pythonhosted.org/packages/30/57/d5cceb0799c06733eefce80c395459f28970ebb9e896846ce96ab579a3f1/torch-1.2.0-cp36-cp36m-manylinux1_x86_64.whl (748.8MB)
    100% |████████████████████████████████| 748.9MB 133kB/s
Collecting numpy (from torch==1.2.0)
  Downloading https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl (13.4MB)
    100% |████████████████████████████████| 13.4MB 4.7MB/s
Installing collected packages: numpy, torch
Successfully installed numpy-1.19.5 torch-1.2.0
Collecting torchvision==0.4.0
  Downloading https://files.pythonhosted.org/packages/06/e6/a564eba563f7ff53aa7318ff6aaa5bd8385cbda39ed55ba471e95af27d19/torchvision-0.4.0-cp36-cp36m-manylinux1_x86_64.whl (8.8MB)
    100% |████████████████████████████████| 8.8MB 6.8MB/s
Requirement already satisfied: numpy in ./.pyenv/versions/3.6.11/lib/python3.6/site-packages (from torch==1.2.0) (1.19.5)
Collecting pillow>=4.1.1 (from torchvision==0.4.0)
  Downloading https://files.pythonhosted.org/packages/df/74/4a981d12fa26b83c9230b67dee44d1361a372e0f22785f093969fd98b964/Pillow-8.3.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (3.0MB)
    100% |████████████████████████████████| 3.0MB 30.4MB/s
Collecting six (from torchvision==0.4.0)
  Using cached https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl
Installing collected packages: pillow, six, torchvision
Successfully installed pillow-8.3.1 six-1.16.0 torchvision-0.4.0

と問題なくインストールすることに成功しました。

準備ができたのでcdqaをインストール

最後に、

pip install cdqa==1.3.9

とすると、以下のような長めのメッセージが出てcdqaのインストールに成功しました。

Collecting cdqa==1.3.9
  Using cached cdqa-1.3.9.tar.gz (45 kB)
Collecting Flask==1.1.1
  Using cached Flask-1.1.1-py2.py3-none-any.whl (94 kB)
Collecting flask_cors==3.0.8
  Using cached Flask_Cors-3.0.8-py2.py3-none-any.whl (14 kB)
Collecting joblib==0.13.2
  Using cached joblib-0.13.2-py2.py3-none-any.whl (278 kB)
Collecting pandas==0.25.0
  Downloading pandas-0.25.0-cp36-cp36m-manylinux1_x86_64.whl (10.5 MB)
Collecting prettytable==0.7.2
  Using cached prettytable-0.7.2.zip (28 kB)
Collecting transformers==2.1.1
  Using cached transformers-2.1.1-py3-none-any.whl (311 kB)
Collecting scikit_learn==0.21.2
  Downloading scikit_learn-0.21.2-cp36-cp36m-manylinux1_x86_64.whl (6.7 MB)
Collecting tika==1.19
  Using cached tika-1.19.tar.gz (24 kB)
Requirement already satisfied: torch==1.2.0 in ./.pyenv/versions/3.6.11/lib/python3.6/site-packages (from cdqa==1.3.9) (1.2.0)
Collecting markdown==3.1.1
  Using cached Markdown-3.1.1-py2.py3-none-any.whl (87 kB)
Collecting tqdm==4.32.2
  Using cached tqdm-4.32.2-py2.py3-none-any.whl (50 kB)
Collecting wget==3.2
  Using cached wget-3.2.zip (10 kB)
Collecting Jinja2>=2.10.1
  Using cached Jinja2-3.0.1-py3-none-any.whl (133 kB)
Collecting Werkzeug>=0.15
  Using cached Werkzeug-2.0.1-py3-none-any.whl (288 kB)
Collecting click>=5.1
  Using cached click-8.0.1-py3-none-any.whl (97 kB)
Collecting itsdangerous>=0.24
  Using cached itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Requirement already satisfied: Six in ./.pyenv/versions/3.6.11/lib/python3.6/site-packages (from flask_cors==3.0.8->cdqa==1.3.9) (1.16.0)
Requirement already satisfied: setuptools>=36 in ./.pyenv/versions/3.6.11/lib/python3.6/site-packages (from markdown==3.1.1->cdqa==1.3.9) (40.6.2)
Requirement already satisfied: numpy>=1.13.3 in ./.pyenv/versions/3.6.11/lib/python3.6/site-packages (from pandas==0.25.0->cdqa==1.3.9) (1.19.5)
Collecting pytz>=2017.2
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting python-dateutil>=2.6.1
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting scipy>=0.17.0
  Downloading scipy-1.5.4-cp36-cp36m-manylinux1_x86_64.whl (25.9 MB)
Collecting requests
  Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
Collecting sentencepiece
  Downloading sentencepiece-0.1.96-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)
Collecting sacremoses
  Using cached sacremoses-0.0.45-py3-none-any.whl (895 kB)
Collecting boto3
  Downloading boto3-1.18.1-py3-none-any.whl (131 kB)
Collecting regex
  Downloading regex-2021.7.6-cp36-cp36m-manylinux2014_x86_64.whl (722 kB)
Collecting importlib-metadata
  Downloading importlib_metadata-4.6.1-py3-none-any.whl (17 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl (30 kB)
Collecting dataclasses
  Downloading dataclasses-0.8-py3-none-any.whl (19 kB)
Collecting jmespath<1.0.0,>=0.7.1
  Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Collecting s3transfer<0.6.0,>=0.5.0
  Downloading s3transfer-0.5.0-py3-none-any.whl (79 kB)
Collecting botocore<1.22.0,>=1.21.1
  Downloading botocore-1.21.1-py3-none-any.whl (7.7 MB)
Collecting urllib3<1.27,>=1.25.4
  Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
Collecting zipp>=0.5
  Downloading zipp-3.5.0-py3-none-any.whl (5.7 kB)
Collecting typing-extensions>=3.6.4
  Using cached typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.2-py3-none-any.whl (59 kB)
Collecting charset-normalizer~=2.0.0
  Downloading charset_normalizer-2.0.3-py3-none-any.whl (35 kB)
Using legacy 'setup.py install' for cdqa, since package 'wheel' is not installed.
Using legacy 'setup.py install' for prettytable, since package 'wheel' is not installed.
Using legacy 'setup.py install' for tika, since package 'wheel' is not installed.
Using legacy 'setup.py install' for wget, since package 'wheel' is not installed.
Installing collected packages: zipp, urllib3, typing-extensions, python-dateutil, jmespath, MarkupSafe, importlib-metadata, dataclasses, botocore, Werkzeug, tqdm, s3transfer, regex, joblib, Jinja2, itsdangerous, idna, click, charset-normalizer, certifi, sentencepiece, scipy, sacremoses, requests, pytz, Flask, boto3, wget, transformers, tika, scikit-learn, prettytable, pandas, markdown, flask-cors, cdqa
    Running setup.py install for wget: started
    Running setup.py install for wget: finished with status 'done'
    Running setup.py install for tika: started
    Running setup.py install for tika: finished with status 'done'
    Running setup.py install for prettytable: started
    Running setup.py install for prettytable: finished with status 'done'
    Running setup.py install for cdqa: started
    Running setup.py install for cdqa: finished with status 'done'
Successfully installed Flask-1.1.1 Jinja2-3.0.1 MarkupSafe-2.0.1 Werkzeug-2.0.1 boto3-1.18.1 botocore-1.21.1 cdqa-1.3.9 certifi-2021.5.30 charset-normalizer-2.0.3 click-8.0.1 dataclasses-0.8 flask-cors-3.0.8 idna-3.2 importlib-metadata-4.6.1 itsdangerous-2.0.1 jmespath-0.10.0 joblib-0.13.2 markdown-3.1.1 pandas-0.25.0 prettytable-0.7.2 python-dateutil-2.8.2 pytz-2021.1 regex-2021.7.6 requests-2.26.0 s3transfer-0.5.0 sacremoses-0.0.45 scikit-learn-0.21.2 scipy-1.5.4 sentencepiece-0.1.96 tika-1.19 tqdm-4.32.2 transformers-2.1.1 typing-extensions-3.10.0.0 urllib3-1.26.6 wget-3.2 zipp-3.5.0
タイトルとURLをコピーしました