Flask Beanstalk部署错误 [英] Flask Beanstalk deployment errors

查看:319
本文介绍了Flask Beanstalk部署错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Python比较陌生,我正在尝试将一个Flask应用程序部署到AWS Beanstalk。我遵循官方教程,并在网上(在这里或其他地方)了解了关于Flask / Django on Beanstalk的部署问题的大量资源。没有成功,我不断收到我无法修复的错误。
在我的应用程序的结构之下:

  | -application.py 
| -config.py
| -const.py
| -requirements.txt
| -app /
| --__ init.py__
| --views.py
| --models.py
| --static /
| --templates /

My application.py

  from app.views import application 

application.run(debug = False)

包含Flask应用程序声明的views.py文件的前几行:

  from flask import Flask,render_template,redirect,url_for,session,request,abort $ b $ from flask_bootstrap import Bootstrap 
来自。模型导入数据层,配置,签署
从。 util import check_user $ b $ from flask_basicauth import BasicAuth $ b $ from flask_bcrypt import bcrypt $ b $ from faker import faker
from htmlmin.minify import html_minify
fake = Faker()


application = app = Flask(__ name__)
app.config.from_object('config')

ootstrap = Bootstrap(app)
basic_auth = BasicAuth(app)
bcrypt = Bcrypt(app)

最后, code> /var/log/eb-activity.log

  SyntaxError:无效的语法
2017-06-07 19:08:18,171错误安装依赖项时出错:命令'/ opt / python / run / venv / bin / pip install -r /opt/python/ondeck/app/requirements.txt'非零退出状态1
Traceback(最近一次调用最后一次):

install_dependencies主文件中的/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py,第22行()
文件/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py,l inet 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,第541行,check_call
提升CalledProcessError(retcode,cmd)
CalledProcessError:命令'/ opt / python / run / venv / bin / pip install -r /opt/python/ondeck/app/requirements.txt返回的非零退出状态1(ElasticBeanstalk :: ExternalInvocationError)
引起的:Traceback(最近一次调用的最后一次):
在< module>文件中的/ opt / python / run / venv / bin / pip
from pip import main
在< module>文件中的/opt/python/run/venv/local/lib/python3.4/site-packages/pip/__init__.py,第15行。
from pip.vcs import git,mercurial,subversion,bazaar#noqa
文件/opt/python/run/venv/local/lib/python3.4/site-packages/pip/vcs/mercurial .py,第10行,在< module>
from pip.download import path_to_url
文件/opt/python/run/venv/local/lib/python3.4/site-packages/pip/download.py,第38行,在<模块>
来自pip._vendor导入请求,六
文件/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/__init__.py,第53行,在< module>
from .packages.urllib3.contrib import pyopenssl
文件/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/__init__。 py,第3行,在< module>
来自。 import urllib3
文件/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py,第10行,在<模块>
from .connectionpool import(
文件/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py第37行,在< module>
from .request import RequestMethods
文件中/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests /packages/urllib3/request.py,第6行,在< module>
from .filepost import encode_multipart_formdata
文件/opt/python/run/venv/local/lib/python3.4/ / opt / python / run / venv /文件中的第3行,在< module>
中创建了site-packages / pip / _vendor / requests / packages / urllib3 / filepost.py本地/ lib / python3.4 / site-packages / uuid.py,第138行
如果不是0 <= time_low <1 <32L:
^
语法错误:无效语法
2017-06-07 19:08:18,171错误安装依赖项错误:命令'/ opt / python / run / venv / bin / pip install -r /opt/python/ondeck/app/requirements.txt'返回的非零退出状态1
Traceback(最近一次调用的最后一个):
文件/ opt / elasticbeanstalk /钩子/ appdeploy / pre / 03deploy.py,第22行,在主
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,第541行,check_call
提升CalledProcessError(retcode,cmd)
CalledProcessError:命令'/ opt / python / run / venv / bin / pip install -r /opt/python/ondeck/app/requirements.txt'返回的非零退出状态1(Executor :: NonZeroExitStatus)

和我的requirements.txt:

  appdirs == 1.4.3 
bcrypt == 3.1。 3
beautifulsoup4 == 4.6.0
cffi == 1.10。 0
点击== 6.7
django-htmlmin == 0.10.0
支配== 2.3.1
Faker == 0.7.12
Flask == 0.12。 2
Flask-BasicAuth == 0.2.0
Flask-Bcrypt == 0.7.1
Flask-Bootstrap == 3.3.7.1
Flask-WTF == 0.14.2
html5lib == 0.999999999
itsdangerous == 0.24
Jinja2 == 2.9.6
MarkupSafe == 1.0
包装== 16.8
pycparser == 2.17
pyparsing == 2.2.0
python-dateutil == 2.6.0
PyYAML == 3.12
请求== 2.14.2
六个== 1.10.0
ua-parser == 0.7.3
user-agents == 1.1.0
uuid == 1.30
visitor == 0.1.3
webencodings == 0.5。 1
Werkzeug == 0.12.2
WTForms == 2.1

我有没有beanstalk配置文件(但),但我已经执行了手动安装: yum install libffi-devel



我的第一个问题是我们如何确定何时需要将 -devel 包添加到我们的部署中? (我在上面安装了devel包,解决了第一个部署问题。)
我认为所有必要的包/库都将与requirements.txt一起安装吗?



我的第二个问题是,你有什么线索,为什么这个部署失败? (有希望被链接到第一个问题?)

在此先感谢您的帮助,



Stf

解决方案

尝试从您的requirements.txt中移除以下行:

<$ p $ uuid == 1.30

uuid 与2.5版本的Python捆绑在一起。


I am relatively new to Python and I am trying to deploy a Flask app to AWS Beanstalk. I have followed the official tutorial and went through a lot of the resources available online (here or elsewhere) regarding deployment issues with Flask / Django on Beanstalk. No success, I keep getting errors I cannot fix. Below the structure of my app:

|-application.py
|-config.py
|-const.py
|-requirements.txt
|-app/
|--__init.py__
|--views.py
|--models.py
|--static/
|--templates/

My application.py

from app.views import application

application.run(debug=False)

The first few lines of my views.py file that contains the declaration of the Flask app:

from flask import Flask, render_template, redirect, url_for, session, request, abort
from flask_bootstrap import Bootstrap
from . models import Datalayer, Config, Signin
from . util import check_user
from flask_basicauth import BasicAuth
from flask_bcrypt import Bcrypt
from faker import Faker
from htmlmin.minify import html_minify
fake = Faker()


application = app = Flask(__name__)
app.config.from_object('config')

bootstrap = Bootstrap(app)
basic_auth = BasicAuth(app)
bcrypt = Bcrypt(app)

And finally the content of the /var/log/eb-activity.log

 SyntaxError: invalid syntax
      2017-06-07 19:08:18,171 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: Traceback (most recent call last):
        File "/opt/python/run/venv/bin/pip", line 7, in <module>
          from pip import main
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/__init__.py", line 15, in <module>
          from pip.vcs import git, mercurial, subversion, bazaar  # noqa
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/vcs/mercurial.py", line 10, in <module>
          from pip.download import path_to_url
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/download.py", line 38, in <module>
          from pip._vendor import requests, six
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/__init__.py", line 53, in <module>
          from .packages.urllib3.contrib import pyopenssl
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/__init__.py", line 3, in <module>
          from . import urllib3
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 10, in <module>
          from .connectionpool import (
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 37, in <module>
          from .request import RequestMethods
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/request.py", line 6, in <module>
          from .filepost import encode_multipart_formdata
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/filepost.py", line 3, in <module>
          from uuid import uuid4
        File "/opt/python/run/venv/local/lib/python3.4/site-packages/uuid.py", line 138
          if not 0 <= time_low < 1<<32L:
                                      ^
      SyntaxError: invalid syntax
      2017-06-07 19:08:18,171 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)

And my requirements.txt:

appdirs==1.4.3
bcrypt==3.1.3
beautifulsoup4==4.6.0
cffi==1.10.0
click==6.7
django-htmlmin==0.10.0
dominate==2.3.1
Faker==0.7.12
Flask==0.12.2
Flask-BasicAuth==0.2.0
Flask-Bcrypt==0.7.1
Flask-Bootstrap==3.3.7.1
Flask-WTF==0.14.2
html5lib==0.999999999
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
packaging==16.8
pycparser==2.17
pyparsing==2.2.0
python-dateutil==2.6.0
PyYAML==3.12
requests==2.14.2
six==1.10.0
ua-parser==0.7.3
user-agents==1.1.0
uuid==1.30
visitor==0.1.3
webencodings==0.5.1
Werkzeug==0.12.2
WTForms==2.1

I have no beanstalk config file (yet) but I have performed a manual install of: yum install libffi-devel

My first question is how do we determine when we need to add -devel packages to our deployment? (I fixed a first deployment issue with the installation of the devel package above.) I assumed all the necessary packages / libraries would be installed with the requirements.txt?

My second question is do you have any clue as to why this deployment is failing? (will hopefully be linked to the first question?)

Thanks in advance for the help,

Stf

解决方案

Try removing the following line from your requirements.txt

uuid==1.30

uuid is bundled with Python as of version 2.5 or so.

这篇关于Flask Beanstalk部署错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆