0
0

More than 1 year has passed since last update.

invalid command 'egg_info' on AWS Amplify Console CI/CD

Last updated at Posted at 2023-06-28

私と同じように、Amplify Consoleの継続デプロイで突然発生したPythonエラーに困っているエンジニアがいると思います。そのため、その解決方法についてメモします。

結論から言いますと、もし2023/06/25日まで以下のビルド設定でうまくデプロイしていたのに、6月26日から「invalid command 'egg_info'」のエラーが出た場合、その原因はpipenvのバージョンにあります。

version: 1
backend:
  phases:
    preBuild:
        commands:
            - export BASE_PATH=$(pwd)
            - yum install -y gcc openssl-devel bzip2-devel libffi-devel python3.8-pip
            - cd /opt && wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
            - cd /opt && tar xzf Python-3.8.2.tgz 
            - cd /opt/Python-3.8.2 && ./configure --enable-optimizations
            - cd /opt/Python-3.8.2 && make altinstall
            - pip3.8 install --user pipenv
            - ln -fs /usr/local/bin/python3.8 /usr/bin/python3
            - ln -fs /usr/local/bin/pip3.8 /usr/bin/pip3
            - cd $BASE_PATH

解決方法:pipenvをインストールする際は、バージョンを指定します。

- pip3.8 install --user pipenv==2023.2.18

問題を調べるため、最初に疑問に思ったのは以下のログでした:

added seed packages: pip==23.1.2, setuptools==67.8.0, wheel==0.40.0

ローカル環境と一致しているため、pipとsetuptoolsのバージョンが問題である可能性は低そうです。
次に考慮に入れたのはpipenvのバージョンです。
preBuild phaseにpipenv --versionを追加してみると、以下のログが出力されました:

 # Executing command: pipenv --version
pipenv, version 2023.6.26

ローカルのpipenvのバージョンは「2023.2.18」です。
これが原因かもしれないと考え、pipenvのバージョンを「2023.2.18」に指定してみたところ、deployがついに成功しました!

0
0
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
0
0