【Python】軽量のHTTPクライアントライブラリ「unirest」のインストールができないことについて書きます。
「unirest(https://github.com/Kong/unirest-python)」は、複数の言語で利用できる軽量のHTTPライブラリのセットです。Mashapeによって構築および保守されています。
■Python
今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)
■unirestをインストールする
unirestをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。
pip install unirest
起動後、上記のコマンドを入力し、Enterキーを押します。
なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。
py -3.8 -m pip install unirest
切り替えるために、上記のコマンドを入力し、Enterキーを押します。
Defaulting to user installation because normal site-packages is not writeable
Collecting unirest
Downloading Unirest-1.1.7.tar.gz (3.8 kB)
Preparing metadata (setup.py) ... done
Collecting poster>=0.8.1
Downloading poster-0.8.1.tar.gz (12 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [11 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "C:\Users\user_\AppData\Local\Temp\pip-install-efvj13g7\poster_0bfe048335e9432e8f585aa0f93d20ae\setup.py", line 2, in
import poster
File "C:\Users\user_\AppData\Local\Temp\pip-install-efvj13g7\poster_0bfe048335e9432e8f585aa0f93d20ae\poster\__init__.py", line 29, in
import poster.streaminghttp
File "C:\Users\user_\AppData\Local\Temp\pip-install-efvj13g7\poster_0bfe048335e9432e8f585aa0f93d20ae\poster\streaminghttp.py", line 61
print "send:", repr(value)
^
SyntaxError: invalid syntax
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、unirestが正常にインストールされたことになりますが、今回はエラーが発生し、インストールできませんでした。
インストールできない原因を調べましたが、依存関係でposterというライブラリのインストールを行っていますが、このライブラリでエラーが発生してしまっていることが原因で、unirestがインストールできないことが判明。さらになぜこのライブラリでエラーが発生しているのかを調べたところ、posterはPython2にしか対応していない模様で、Python3互換はおそらく実装されていないということがわかりました(https://stackoverflow.com/questions/54066927/python-pip-install-poster-gives-me-error-command-python-setup-py-egg-info)。


コメント