0

I've a Django project running on AWS with Django1.11 and Python 2.7.

I am upgrading it to Django 2.2 and Python 3.6

I have it running locally and all tests pass. I am not trying to load it onto an AWS elasticbeanstalk instance.

When I do eb deploy, I am getting the following error in the eb activity log

[2019-10-10T14:06:38.123Z] INFO  [19195] - [Application update app-1cfe-191010_140828@14/AppDeployStage0/AppDeployPreHook/03deploy.py] : Activity execution failed, because: Traceback (most recent call last):
    File "/opt/python/run/venv/bin/pip", line 4, in <module>
      import re
    File "/opt/python/run/venv/lib64/python3.6/re.py", line 142, in <module>
      class RegexFlag(enum.IntFlag):
  AttributeError: module 'enum' has no attribute 'IntFlag'
  2019-10-10 14:06:38,116 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
      install_dependencies()
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
      check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
    File "/usr/lib64/python2.7/subprocess.py", line 190, 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 (ElasticBeanstalk::ExternalInvocationError)
caused by: Traceback (most recent call last):
    File "/opt/python/run/venv/bin/pip", line 4, in <module>
      import re
    File "/opt/python/run/venv/lib64/python3.6/re.py", line 142, in <module>
      class RegexFlag(enum.IntFlag):
  AttributeError: module 'enum' has no attribute 'IntFlag'
  2019-10-10 14:06:38,116 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
      install_dependencies()
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
      check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
    File "/usr/lib64/python2.7/subprocess.py", line 190, 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 (Executor::NonZeroExitStatus)

The Python2.7 version was using enum34 (in requirements.txt) which I've deleted/uninstalled so I don't believe that is the issue.

I also do not understand why I'm getting the line File "/usr/lib64/python2.7/subprocess.py", line 190, in check_call raise CalledProcessError(retcode, cmd). Why would it be trying to use Python2.7 - what haven't I amended that I should? Can anyone help?

NOTE

Although this is the same error Why Python 3.6.1 throws AttributeError: module 'enum' has no attribute 'IntFlag'?, it doesn't help me solve on AWS through the eb deploy process

HenryM
  • 5,557
  • 7
  • 49
  • 105
  • 1
    I had a lot of problems when I upgrade version of Python from 2 to 3.6, various libs changed name or does not exists anymore. And some libs change their methods, can be your case. – Paulo Henrique Oct 10 '19 at 16:56
  • When I ssh into the instance and run `python --version` it shows 2.7.x but I thought this platform (`Python 3.6 running on 64bit Amazon Linux/2.9.2`) was meant to be python 3.6. If I check `python3 --version` then it is 3.6.8 installed – HenryM Oct 10 '19 at 18:11

1 Answers1

0

The issue seems to have been I was changing environment variables via the console (eg setting wsgi.py) whereas I needed to leave the deploy to manage that and just set the database settings

HenryM
  • 5,557
  • 7
  • 49
  • 105