【Docker】Ubuntu に docker-compose をインストールしたかった(Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hqdra608/cryptography/ エラー)
環境
Ubuntu 18.04.5
Docker 20.10.8
やりたいこと
- docker-compose をインストールしたい
事象
# python3 と python3-pip をインストール $ sudo apt install -y python3 python3-pip # pip3 を使って、docker-compose をインストール $ sudo pip3 install docker-compose # 失敗した Collecting cryptography>=2.5 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]>=5->docker-compose) Downloading https://files.pythonhosted.org/packages/cc/98/8a258ab4787e6f835d350639792527d2eb7946ff9fc0caca9c3f4cf5dcfe/cryptography-3.4.8.tar.gz (546kB) 100% |████████████████████████████████| 552kB 2.4MB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-hqdra608/cryptography/setup.py", line 14, in <module> from setuptools_rust import RustExtension ModuleNotFoundError: No module named 'setuptools_rust' =============================DEBUG ASSISTANCE========================== If you are seeing an error here please try the following to successfully install cryptography: Upgrade to the latest pip and try again. This will fix errors for most users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip =============================DEBUG ASSISTANCE========================== ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hqdra608/cryptography/
解決方法
上記のメッセージより、Upgrade to the latest pip and try again. This will fix errors for most users
「最新の pip にアップグレードしてください」とあるので、アップグレードを試してみる
# アップグレードする $ sudo pip3 install --upgrade pip --- 省略 --- # アップグレードできた Successfully installed pip-21.2.4
# pip3 を使って、docker-compose をインストール(再) $ sudo pip3 install docker-compose --- 省略 --- # インストールできた! Successfully installed bcrypt-3.2.0 cached-property-1.5.2 cffi-1.14.6 charset-normalizer-2.0.4 cryptography-3.4.8 distro-1.6.0 docker-5.0.2 docker-compose-1.29.2 dockerpty-0.4.1 docopt-0.6.2 paramiko-2.7.2 pycparser-2.20 pynacl-1.4.0 python-dotenv-0.19.0 requests-2.26.0 texttable-1.6.4 websocket-client-0.59.0 # 念のため確認 $ docker-compose --version docker-compose version 1.29.2, build unknown