0
votes

I have a Django 1.11 app I deploy on ElasticBeanstalk Python 2.7 platform. After updating some of my requirements, it seems pip is failing on EB. Weird because it works on my local Python 2.7.16 env (MacOS 10.15.1 default) just fine.

Here's the error shown in the EB application logs:

[Instance: i-07622227350cdbc48] Command failed on instance. Return code: 1 Output: (TRUNCATED)...) File "/usr/lib64/python2.7/subprocess.py", line 541, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

1

1 Answers

0
votes

Ok, I dove into the eb-activity.log and found a few lines where the cause for this exit status 1 is mentioned. Specially:

...
error in enum-compat setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in enum34; python_version < "3.4" at ; python_version < "3.4"

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-0u2vRJ/enum-compat
You are using pip version 7.1.2, however version 20.0.2 is available.
...

And after searching around, I realized this is related to this issue: https://github.com/jstasiak/enum-compat/pull/4 (enum-compat is a requirement of one of my project's requirements, intuit-oauth). The fix to that issue caused older versions of setuptools to break when installing it, as explained in this comment.

That means pip! And as it can be seen in the log snippet above, for some reason EB uses pretty old versions. WHICH IS DUMB BUT OK.

Fortunately, there was an update available for my Python app platform (64bit Amazon Linux 2018.03 v2.9.4) on EB which although only goes up to pip 9 (out of 20...), was enough to solve this for me. Otherwise I would've had to use a preinit hook (via .ebextensions files field) to upgrade pip, or something annoying like that.

However, since the las deployment had failed, the platform upgrade also didn't work... I had to redeploy an old version that still worked first, then upgrade the Python platform, and THEN deploy my new code again.

I also recommend this answer to debug other similar issues: https://stackoverflow.com/a/47093980/761963