AWS ElasticBeanStalk错误

时间:2017-04-18 02:17:15

标签: python django amazon-web-services amazon-elastic-beanstalk

我正在尝试使用ElasticBeanStalk放置基于Django的WebApp,但是在部署过程中,我得到了一些错误,请检查日志文件。我搜索了日志文件但无法理解错误,任何人都可以帮助我了解发生了什么?

Logs:
 * The following required packages can not be built:
 * freetype

      ----------------------------------------
  Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-n5etdtzo/matplotlib/
  2017-04-18 02:06:43,611 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 (ElasticBeanstalk::ExternalInvocationError)
caused by: Requirement already satisfied: appdirs==1.4.3 in /opt/python/run/venv/lib/python3.4/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 1))
  Requirement already satisfied: aws-requests-auth==0.3.0 in /opt/python/run/venv/lib/python3.4/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 2))
  Collecting awscli==1.11.61 (from -r /opt/python/ondeck/app/requirements.txt (line 3))
    Using cached awscli-1.11.61-py2.py3-none-any.whl
  Collecting awsebcli==3.10.0 (from -r /opt/python/ondeck/app/requirements.txt (line 4))
    Using cached awsebcli-3.10.0.tar.gz
  Collecting backports.ssl-match-hostname==3.5.0.1 (from -r /opt/python/ondeck/app/requirements.txt (line 5))
    Using cached backports.ssl_match_hostname-3.5.0.1.tar.gz
  Collecting bdist-mpkg==0.5.0 (from -r /opt/python/ondeck/app/requirements.txt (line 6))
    Using cached bdist_mpkg-0.5.0.tar.gz
  Collecting blessed==1.14.1 (from -r /opt/python/ondeck/app/requirements.txt (line 7))
    Using cached blessed-1.14.1-py2.py3-none-any.whl
  Requirement already satisfied: boto3==1.4.4 in /opt/python/run/venv/lib/python3.4/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 8))
  Collecting botocore==1.5.24 (from -r /opt/python/ondeck/app/requirements.txt (line 9))
    Using cached botocore-1.5.24-py2.py3-none-any.whl
  Collecting cement==2.8.2 (from -r /opt/python/ondeck/app/requirements.txt (line 10))
    Using cached cement-2.8.2.tar.gz
  Collecting colorama==0.3.7 (from -r /opt/python/ondeck/app/requirements.txt (line 11))
    Using cached colorama-0.3.7-py2.py3-none-any.whl
  Requirement already satisfied: Django==1.10.6 in /opt/python/run/venv/lib/python3.4/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 12))
  Collecting django-extensions==1.7.7 (from -r /opt/python/ondeck/app/requirements.txt (line 13))
    Using cached django_extensions-1.7.7-py2.py3-none-any.whl
  Collecting django-extensions-shell==1.7.4.1 (from -r /opt/python/ondeck/app/requirements.txt (line 14))
    Using cached django_extensions_shell-1.7.4.1-py2.py3-none-any.whl
  Collecting docker-py==1.7.2 (from -r /opt/python/ondeck/app/requirements.txt (line 15))
    Using cached docker-py-1.7.2.tar.gz
  Collecting dockerpty==0.4.1 (from -r /opt/python/ondeck/app/requirements.txt (line 16))
    Using cached dockerpty-0.4.1.tar.gz
  Collecting docopt==0.6.2 (from -r /opt/python/ondeck/app/requirements.txt (line 17))
    Using cached docopt-0.6.2.tar.gz
  Requirement already satisfied: docutils==0.13.1 in /opt/python/run/venv/lib/python3.4/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 18))
  Collecting elasticsearch==5.2.0 (from -r /opt/python/ondeck/app/requirements.txt (line 19))
    Using cached elasticsearch-5.2.0-py2.py3-none-any.whl
  Collecting futures==3.0.5 (from -r /opt/python/ondeck/app/requirements.txt (line 20))
    Using cached futures-3.0.5.tar.gz
  Requirement already satisfied: jmespath==0.9.2 in /opt/python/run/venv/lib/python3.4/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 21))
  Collecting macholib==1.5.1 (from -r /opt/python/ondeck/app/requirements.txt (line 22))
    Using cached macholib-1.5.1.tar.gz
  Collecting matplotlib==1.3.1 (from -r /opt/python/ondeck/app/requirements.txt (line 23))
    Using cached matplotlib-1.3.1.tar.gz
      Complete output from command python setup.py egg_info:
      ============================================================================
      Edit setup.cfg to change the build options

      BUILDING MATPLOTLIB
                  matplotlib: yes [1.3.1]
                      python: yes [3.4.3 (default, Sep  1 2016, 23:33:38)  [GCC
                              4.8.3 20140911 (Red Hat 4.8.3-9)]]
                    platform: yes [linux]

      REQUIRED DEPENDENCIES AND EXTENSIONS
                       numpy: yes [not found. pip may install it below.]
                    dateutil: yes [using dateutil version 2.6.0]
                     tornado: yes [tornado was not found. It is required for the
                              WebAgg backend. pip/easy_install may attempt to
                              install it after matplotlib.]
                   pyparsing: yes [using pyparsing version 2.2.0]
                       pycxx: yes [Official versions of PyCXX are not compatible
                              with Python 3.x.  Using local copy]
                      libagg: yes [pkg-config information for 'libagg' could not
                              be found. Using local copy.]
                    freetype: no  [pkg-config information for 'freetype2' could
                              not be found.]
                         png: yes [pkg-config information for 'libpng' could not
                              be found. Using unknown version.]

      OPTIONAL SUBPACKAGES
                 sample_data: yes [installing]
                    toolkits: yes [installing]
                       tests: yes [nose 0.11.1 or later is required to run the
                              matplotlib test suite]

      OPTIONAL BACKEND EXTENSIONS
                      macosx: no  [Mac OS-X only]
                      qt4agg: no  [PyQt4 not found]
                     gtk3agg: no  [gtk3agg backend does not work on Python 3]
                   gtk3cairo: no  [Requires cairo to be installed.]
                      gtkagg: no  [Requires pygtk]
                       tkagg: no  [TKAgg requires Tkinter.]
                       wxagg: no  [requires wxPython]
                         gtk: no  [Requires pygtk]
                         agg: yes [installing]
                       cairo: no  [cairo not found]
                   windowing: no  [Microsoft Windows only]

      OPTIONAL LATEX DEPENDENCIES
                      dvipng: no
                 ghostscript: no
                       latex: no
                     pdftops: no

      ============================================================================
                              * The following required packages can not be built:
                              * freetype

      ----------------------------------------
  Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-n5etdtzo/matplotlib/
  2017-04-18 02:06:43,611 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)


[2017-04-18T02:06:43.630Z] INFO  [3334]  - [Application update 7@5/AppDeployStage0/AppDeployPreHook/03deploy.py] : Activity failed.
[2017-04-18T02:06:43.630Z] INFO  [3334]  - [Application update 7@5/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2017-04-18T02:06:43.630Z] INFO  [3334]  - [Application update 7@5/AppDeployStage0] : Activity failed.
[2017-04-18T02:06:43.631Z] INFO  [3334]  - [Application update 7@5] : Completed activity. Result:
  Application update - Command CMD-AppDeploy failed
[2017-04-18T02:07:43.802Z] INFO  [3482]  - [CMD-BundleLogs] : Starting activity...
[2017-04-18T02:07:43.802Z] INFO  [3482]  - [CMD-BundleLogs/AddonsBefore] : Starting activity...
[2017-04-18T02:07:43.802Z] INFO  [3482]  - [CMD-BundleLogs/AddonsBefore] : Completed activity.
[2017-04-18T02:07:43.803Z] INFO  [3482]  - [CMD-BundleLogs/BundleLogs] : Starting activity...
[2017-04-18T02:07:43.803Z] INFO  [3482]  - [CMD-BundleLogs/BundleLogs/BundleLogs] : Starting activity...



My requirements.txt file is
appdirs==1.4.3
aws-requests-auth==0.3.0
awscli==1.11.61
awsebcli==3.10.0
backports.ssl-match-hostname==3.5.0.1
bdist-mpkg==0.5.0
blessed==1.14.1
boto3==1.4.4
botocore==1.5.24
cement==2.8.2
colorama==0.3.7
Django==1.10.6
django-extensions==1.7.7
django-extensions-shell==1.7.4.1
docker-py==1.7.2
dockerpty==0.4.1
docopt==0.6.2
docutils==0.13.1
elasticsearch==5.2.0
futures==3.0.5
jmespath==0.9.2
macholib==1.5.1
matplotlib==1.3.1
modulegraph==0.10.4
numpy==1.8.0rc1
oauthlib==2.0.1
packaging==16.8
pathspec==0.5.0
py2app==0.7.3
pyasn1==0.2.3
pyparsing==2.2.0
pysolr==3.6.0
python-dateutil==2.6.0
pytz==2013.7
PyYAML==3.12
requests==2.9.1
requests-oauthlib==0.8.0
rsa==3.4.2
s3transfer==0.1.10
scipy==0.13.0b1
semantic-version==2.5.0
six==1.10.0
tabulate==0.7.5
termcolor==1.1.0
tweepy==3.5.0
urllib3==1.20
vboxapi==1.0
virtualenv==15.1.0
watson-developer-cloud==0.25.2
wcwidth==0.1.7
websocket-client==0.40.0
xattr==0.6.4
zope.interface==4.1.1

我正在使用Pycharm进行开发,但使用pip freeze命令来生成这些要求。

Update1:​​我删除了一些要求并成功部署,但在尝试从链接访问webapp时遇到Server 500错误。

1 个答案:

答案 0 :(得分:0)

Elastic Beanstalk正在尝试逐个安装您的requirements.txt项目,但它会在" egg_info"处停止。这是错误:

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-n5etdtzo/matplotlib/

我猜你没有为本地开发使用虚拟环境。这就是为什么你在requirements.txt中看到所有不必要的项目的原因:

您有两种选择:

  1. 尝试在您的实例上手动安装(或删除)那些发生错误的操作(在每次部署失败后逐个安装)。为此,您必须直接连接到您的EC2,然后pip installsudo pip install。您可能需要重复几次此过程。

  2. (无法尽快切换到此方法)创建一个简单的virtualenv并选择真正需要的要求,然后再次尝试部署。

  3. 创建新环境:

    cd my_app
    
    virtualenv .
    

    激活env:

    source bin/activate
    

    创建新的requirement.txt

    pip freeze > requirements.txt
    

    只添加NECESSARY项目,并完成!