11

I am trying to deploy the first zappa example app built with Flask-Ask, It looks like everything works good but after the Deploying API statement I get the following error :

Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

Here is the code I am executing with minor changes to the sample app

from flask import Flask
from flask_ask import Ask, question, statement, session
import pyodbc

app = Flask(name)
ask = Ask(app, '/')

@ask.intent('HelloIntent')
def hello(firstname):
speech_text = "Hello %s" % firstname
return statement(speech_text).simple_card('Hello', speech_text)

@ask.intent('ByeIntent')
def bye():
return statement("Ok, goodBye!")



if name == 'main':
app.run()
  • Zappa version used: 0.46.1
  • Operating System and Python version: Windows 7, Python 3.6

Can someone please help me out here?

s_om
  • 443
  • 6
  • 17
  • Could you please make one change at a time to the sample app, then identify a single line that causes your problem? Introducing an entire new library is not a minor change--in particular, adding Alexa means that there's a whole set of permissions that could be coming into play. Did you look at your Cloudwatch logs? – David Bruce Borenstein Jun 20 '18 at 11:47

10 Answers10

9

try installing all the dependencies using pip in the virtual environment where you are using zappa. It worked in my case.

You can also use zappa tail command to see your logs.

Aman Agarwal
  • 495
  • 5
  • 15
  • Good advice! I can see the error as : pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 11 for SQL Server' : file not found (0) (SQLDriverConnect)") The same code works on my local environment though – s_om Jun 21 '18 at 06:57
  • See if [this answer](https://stackoverflow.com/a/49269603/7546606) helps – Aman Agarwal Jun 21 '18 at 08:29
  • 2
    Wow, I feel like an idiot. I had forgotten to pip install flask. Not sure how it was working locally... – ScottieB Jul 05 '18 at 14:55
  • 1
    `Flask` was certainly installed _system-wide_ by another package – freezed Feb 24 '19 at 21:47
2

This github issue seems to have the same symptoms. Downgrading to zappa==0.45.1 solved it for me

zsoobhan
  • 1,334
  • 13
  • 18
2

If you are using anaconda than create a new virtual environment "virtualenv lambda" in your project directory and in Scripts/activate. Than deactivate the conda environment with "conda deactivate" and pip install all the packages "pip install numpy pandas sklearn zappa flask".

PS: using "slim_handle"=true also gives this error, so don't use it.

Saahil
  • 54
  • 4
2

If all of above doesn't work you can solve it by this way.

  • First solve all errors by checking the app log by zappa tail [app name], if you have any

Then, You must provide "app_function" parameter in the zappa_settings.json which should point to your entry function. The app_function should be provided like this if application is Flask __init__.application, so the flask app should be defined as application as follows,

application = Flask(__name__)

app.py should be __init__.py You have to add __init__.py in order to recognize your project folder as a package. So zappa_settings.json have parameter like this,

"app_function": "__init__.application",

Deploy and enjoy!

SarahJessica
  • 331
  • 3
  • 13
Dinuka Salwathura
  • 700
  • 11
  • 25
1

I was facing this error when I gave the modular path to my application as main.py.

I fixed it by creating an empty file called main.app just next to main.py and setting app_function to main.app in zappa_settings.json.

Absolutely no clue what happened underneath, but it worked for me.

0

I had same problem. After spending couple of hours, from cloudwatch logs I noticed the error of sec certificate. Solved it by running "pip install 'cryptography<2.2'"

Nishank
  • 93
  • 2
  • 9
0

I faced the same error, and same what happened with ScottieB above, the reason was that I forgot to do the pip install for one package that my .app was using...After I did the pip install locally in the project environment then did the zappa update dev the error gone! and update been completed.

HassanSh__3571619
  • 1,039
  • 1
  • 12
  • 13
0

I had this same error and after many online searches and trying many, many suggestions, it was actually just a small problem with a code indentation! No problem with Zappa config or pip installations at all.

I notice that in your code sample you have not indented your code at all. I don't know if this is how it copy pasted into StackOverflow or if this is how you unintentionally tried to deploy it. It should be

@ask.intent('HelloIntent')
def hello(firstname):
    speech_text = "Hello %s" % firstname
    return statement(speech_text).simple_card('Hello', speech_text)

@ask.intent('ByeIntent')
def bye():
    return statement("Ok, goodBye!")


if name == 'main':
    app.run()
SarahJessica
  • 331
  • 3
  • 13
0

I was getting same error. check you have installed zappa in your venv. I have installed globally and run in local venv. When i installed zappa it works perfect.

manmohan
  • 370
  • 2
  • 13
0

I was facing the same issue and I figured out that zappa is installed globally on my system not in the virtual env that I am using.

try installing zappa in virtual env

pip install zappa
Kishan Mehta
  • 2,012
  • 1
  • 30
  • 48