【发布时间】:2019-10-11 19:11:46
【问题描述】:
我有一个使用 Django1.11 和 Python 2.7 在 AWS 上运行的 Django 项目。
我正在将它升级到 Django 2.2 和 Python 3.6
我让它在本地运行并且所有测试都通过了。我不想将它加载到 AWS elasticbeanstalk 实例上。
当我执行eb deploy 时,我在 eb 活动日志中收到以下错误
[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)
Python2.7 版本使用的是我已删除/卸载的 enum34(在 requirements.txt 中),所以我认为这不是问题。
我也不明白为什么我收到File "/usr/lib64/python2.7/subprocess.py", line 190, in check_call
raise CalledProcessError(retcode, cmd) 这条线。为什么要尝试使用 Python2.7 - 我没有修改我应该修改的内容?
有人可以帮忙吗?
注意
虽然这是相同的错误Why Python 3.6.1 throws AttributeError: module 'enum' has no attribute 'IntFlag'?,但它并不能帮助我通过eb deploy 进程在 AWS 上解决
【问题讨论】:
-
我在将 Python 版本从 2 升级到 3.6 时遇到了很多问题,各种库更改名称或不再存在。有些库会改变他们的方法,这可能是你的情况。
-
当我 ssh 进入实例并运行
python --version它显示 2.7.x 但我认为这个平台 (Python 3.6 running on 64bit Amazon Linux/2.9.2) 应该是 python 3.6。如果我检查python3 --version那么它是 3.6.8 安装
标签: python django amazon-elastic-beanstalk