【发布时间】:2018-09-26 22:27:45
【问题描述】:
我对 AWS 和一般编码非常陌生。我编写了一个小型 Django 应用程序,现在我正尝试借助此 URL 使用弹性 beanstalk 将其部署在 AWS 上。 https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
我的应用程序使用我需要 psycopg2 包的 Postgres 数据库,我已将其添加到我的 requirements.txt 文件中。 (这不是此 URL 说明的一部分,但我知道我需要 psycopg2,所以我添加了)
当我使用 eb create django-env 创建 EB 环境时,我收到以下错误:
我从 EC2 /var/log/ 获取的此日志。
这里是错误:
[2018-09-26T21:44:20.502Z] INFO [3151] - [应用程序部署 app-d840-180926_224155@1/StartupStage0/AppDeployPreHo ok/03deploy.py] :开始活动... [2018-09-26T21:44:21.774Z] 信息 [3151] - [应用部署 app-d840-180926_224155@1/StartupStage0/AppDeployPreHo ok/03deploy.py] : 活动执行失败,因为:采集雪花石膏==0.7.10 (来自 -r /opt/python/ondeck/app/requi rements.txt(第 1 行)) 正在下载https://files.pythonhosted.org/packages/2e/c3/9b7dcd8548cf2c00531763ba154e524af575e8f36701bacfe5bcadc674 40/alabaster-0.7.10-py2.py3-none-any.whl 正在收集 anaconda-client==1.6.9(来自 -r /opt/python/ondeck/app/requirements.txt(第 2 行) 找不到满足要求 anaconda-client==1.6.9 的版本(来自 -r /opt/python/ondeck/app/requi rements.txt(第 2 行))(来自版本:1.1.1、1.2.2)无匹配 为 anaconda-client==1.6.9 找到分布(来自 -r /opt/python/ondeck/app/requirements.txt(第 2 行)) 您正在使用 pip 版本 9.0.1,但版本 18.0 可用。 你应该 考虑通过“pip install --upgrade pip”命令进行升级。
2018-09-26 21:44:21,768 错误安装依赖项时出错: 命令'/opt/python/run/venv/bin/pip install -r /opt/ python/ondeck/app/requirements.txt' 返回非零退出状态 1
回溯(最近一次通话最后): 文件“/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py”,第 22 行,在 main install_dependencies() 文件“/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py”,第 18 行,在 install_dependencies check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True) 文件“/usr/lib64/python2.7/subprocess.py”,第 186 行,在 check_call 中 raise CalledProcessError(retcode, cmd) CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' 返回非零退出 状态 1 (Executor::NonZeroExitStatus)
我的Django项目settings.py文件有psycopg2
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'test',
'USER': 'postgres',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '5432',
'TEST': {
'NAME': 'testdb',
},
}
}
[编辑] 我的 requirements.txt 文件是:
c:\Users\abhi\OneDrive\Python-Projects\myproject>cat requirements.txt
Django==2.1.1
psycopg2==2.7.5
pytz==2018.5
我的问题是:
- 如何解决此问题?
- 为什么会说您使用的是 pip 9.0.1 版本,但是 18.0 版本可用?我使用的是 pip 18.0,我确定。
- 为什么说 - Collecting anaconda-client==1.6.9 ?我想安装
psycopg2,而不是anaconda。
这是我的副业,我不知道如何解决它。
【问题讨论】:
标签: python django amazon-web-services amazon-elastic-beanstalk