Elastic Beanstalk上的Django“requirements.txt”无效

时间:2016-12-13 16:54:40

标签: django elastic-beanstalk

我正在尝试使用Elastic Beanstalk cli部署django项目。我按照Official Amazon Tutorial以及realpython.com上的本教程进行了操作。 只要我坚持使用pip的视图依赖项来创建一个新创建的Django项目,Deploymentprocess就可以正常工作。

使用我的Django项目尝试时部署失败,因为//date is 14-Dec-2016 let day = 14; let month = 12; let year = 2016; let TimezoneOffset = -480; //Timezone is GMT+0800 (Malay Peninsula Standard Time) let time = 19:34; //in HHMM format 无效。我在我的requirements.txt内创建了这样的内容:virutalenv

pip freeze > requirements.txt

在我的绝望中,我试图逐个激活依赖项。部署过程非常缓慢,我放弃了一段时间。但现在我知道braintree==3.32.0 cffi==1.9.1 cryptography==1.7 Django==1.10.4 django-allauth==0.29.0 django-betterforms==1.1.4 django-contrib-comments==1.7.3 django-formtools==1.0 django-payments==0.9.6 django-tinymce==2.4.0 enum34==1.1.6 idna==2.1 ipaddress==1.0.17 oauthlib==2.0.1 Pillow==3.4.2 pyasn1==0.1.9 pycparser==2.17 PyJWT==1.4.2 python-openid==2.2.5 requests==2.12.3 requests-oauthlib==0.7.0 six==1.10.0 stripe==1.43.0 suds-jurko==0.6 xmltodict==0.10.2 Django==1.10.4, django-allauth==0.29.0, django-betterforms==1.1.4, django-contrib-comments==1.7.3, django-formtools==1.0不是问题所在。 django-tinymce==2.4.0失败但它不是导致问题的唯一依赖。

这是我的django-payments==0.9.6

activity.log

我无法与丢失的软件有关。我知道如何使用 error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/opt/python/run/venv/bin/python2.7 -c "import setuptools, tokenize; __file__='/tmp/pip-build-BF9Oen/cffi/setup.py'; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BsXWzo-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/python/run/venv/include/site/python2.7/cffi" failed with error code 1 in /tmp/pip-build-BF9Oen/cffi You are using pip version 7.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. 2016-12-13 14:49:05,155 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 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 (Executor::NonZeroExitStatus) 文件,但我不知道丢失了什么。是否有本地调试方法?

2 个答案:

答案 0 :(得分:5)

你似乎遇到了FFI和Python的问题。您正在使用密码术,但可能没有所有必需的库安装Python和FFI要求以及用于加密的OpenSSL依赖项。

$ eb ssh                                    # SSH into your EB environment
$ sudo su                                   # gain root privileges
$ yum install python-devel                  # or python27-devel
$ yum install libffi-devel                  # CFFI / FFI requirements
$ yum install openssl-devel                 # Cryptography requirements

如果Pip抱怨,请确保安装了最新的pip:

# repeat SSH and root privilege steps
$ source /opt/python/run/venv/bin/activate  # activate Python environment
$ pip install --upgrade pip                 # upgrade to latest pip

要使更改成为永久更改,请将它们附加到EB配置中。如果您没有直接SSH访问权限,这也可以。

# .ebextensions/10_packages.config excerpt
packages:
  yum:
    gcc: []
    libffi-devel: []
    openssl-devel: []
    python-devel: []  # or python27-devel
带有.ebextensions后缀的

.config文件夹文件是Elastic Beanstalk环境的状态声明。也就是说,当您运行eb deploy或您的CI环境将代码部署到EB时,它们是在每个Elastic Beanstalk部署上运行的指令。

Amazon Linux是一个基于RPM的Linux,它使用YUM进行包管理。您将找到有关Python软件包安装的RHEL / CentOS / OpenSUSE指令,有助于Amazon Linux发行版。

答案 1 :(得分:0)

通常没有办法在本地调试这些问题,因为人们通常不会在本地计算机上运行Amazon linux,并且EB有一个非常特定的环境设置,不容易重现(至少它不是'对我而言。)

如果您想快速完成,只需ssh到您的某个EB / EC2实例,并尝试手动逐个安装点数要求。如果你想做得对,你必须逐个完成这个要求列表。 (即,从需求文件中的一个需求开始,部署,然后是两个需求,然后是三个需求等)。您可能希望通过添加

来升级pip
Stream<Integer> s = Stream.of(1,2,3,4,5);
Stream<Stream<Integer>> separated = split(s, 2);
// after that separated should contain stream(1,2), stream(3,4), stream(5)

在您的需求文件的顶部,并确保安装以下Amazon Linux(如果这是您正在使用的):

pip==9.0.1