【发布时间】:2020-10-28 02:18:21
【问题描述】:
我正在尝试在 Elastic Beanstalk 上部署我的 django 项目。我正在关注官方文档和this article,我认为我已经正确地完成了这些资源中要求的大部分事情。
但我的部署每次都失败。在eb logs 我发现了这个错误
No matching distribution found for pkg-resources==0.0.0 (from -r /opt/python/ondeck/app/requirements.txt (line 27))
You are using pip version 9.0.1, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
2020-07-07 18:19:51,388 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)
到目前为止,我的问题似乎与this stackoverflow question 非常相似,但事实并非如此。我从 requirements.txt 中删除了pkg-resources==0.0.0,但它仍然给我同样的错误。
我的requirements.txt
asgiref==3.2.10
attrs==19.3.0
awsebcli==3.18.1
bcrypt==3.1.7
blessed==1.17.8
botocore==1.15.49
cached-property==1.5.1
cement==2.8.2
certifi==2020.6.20
cffi==1.14.0
chardet==3.0.4
colorama==0.4.3
cryptography==2.9.2
Django==3.0.8
django-cors-headers==3.3.0
djangorestframework==3.11.0
djangorestframework-simplejwt==4.4.0
docker==4.2.2
docker-compose==1.25.5
dockerpty==0.4.1
docopt==0.6.2
docutils==0.15.2
future==0.16.0
idna==2.7
importlib-metadata==1.7.0
jmespath==0.10.0
jsonschema==3.2.0
paramiko==2.7.1
pathspec==0.5.9
psycopg2-binary==2.8.5
pycparser==2.20
PyJWT==1.7.1
PyNaCl==1.4.0
pyrsistent==0.16.0
python-dateutil==2.8.0
pytz==2020.1
PyYAML==5.3.1
requests==2.20.1
semantic-version==2.5.0
six==1.11.0
sqlparse==0.3.1
termcolor==1.1.0
texttable==1.6.2
urllib3==1.24.3
wcwidth==0.1.9
websocket-client==0.57.0
zipp==3.1.0
我已经尝试启动新应用程序和新环境 5 次了,但没有任何改变。
【问题讨论】:
-
看来您正在运行 Amazon Linux 1。我在 EB 上使用 AL2 运行您的
requirements.txt,没有任何问题。您是否特别想使用 AL1? -
我没有,但我想既然我在本地使用 python 3.6.9,我应该使用 AL1 和 3.6。我猜他们只有 AL2 for python 3.7。
-
是的。您可以登录到您的 EB 实例,然后手动运行 pip 命令(或安装整个应用程序)吗?这将告诉我们问题是仅在自动部署期间出现,还是在手动完成时出现。
-
如何在 EB 实例中运行 pip 命令?
-
错误信息提示:
/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt手动运行时可能把requirements.txt改成文件所在的位置
标签: python django amazon-web-services amazon-elastic-beanstalk