Elastic Beanstalk上的Django"requirements.txt"无效

Lon*_*nyT 2 django amazon-elastic-beanstalk

我正在尝试使用Elastic Beanstalk cli部署django项目.我在realpython.com关注官方亚马逊教程以及本教程.只要我坚持使用pip的视图依赖关系来创建新创建的Django项目,Deploymentprocess就可以正常工作.

使用我的Django项目尝试时部署失败,因为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
Run Code Online (Sandbox Code Playgroud)

在我的绝望中,我试图逐个激活依赖项.部署过程非常缓慢,我放弃了一段时间.但现在,我现在知道了,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)
Run Code Online (Sandbox Code Playgroud)

我不知道与丢失的软件有什么关系.我知道如何使用这些.ebextensions .config文件,但我不知道丢失了什么.是否有本地调试方法?

Ale*_*kli 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
Run Code Online (Sandbox Code Playgroud)

如果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
Run Code Online (Sandbox Code Playgroud)

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

# .ebextensions/10_packages.config excerpt
packages:
  yum:
    gcc: []
    libffi-devel: []
    openssl-devel: []
    python-devel: []  # or python27-devel
Run Code Online (Sandbox Code Playgroud)

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

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