You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to deploy or update, the process works well except for the final status check. It 502s because it can't import handler module, which is weird because that's generated by zappa not me.
The output of zappa tail:
[1733249897767] INIT_REPORT Init Duration: 2021.74 ms Phase: invoke Status: error Error Type: Runtime.ImportModuleError
[1733250008792] [ERROR] Runtime.ImportModuleError: Unable to import module 'handler': attempted relative import with no known parent package
Traceback (most recent call last):
[1733250009050] INIT_REPORT Init Duration: 2024.93 ms Phase: invoke Status: error Error Type: Runtime.ImportModuleError
[1733250072033] [ERROR] Runtime.ImportModuleError: Unable to import module 'handler': attempted relative import with no known parent package
Traceback (most recent call last):
[1733250072290] INIT_REPORT Init Duration: 1999.91 ms Phase: invoke Status: error Error Type: Runtime.ImportModuleError
[1733250135174] [ERROR] Runtime.ImportModuleError: Unable to import module 'handler': attempted relative import with no known parent package
Traceback (most recent call last):
[1733250135434] INIT_REPORT Init Duration: 1988.36 ms Phase: invoke Status: error Error Type: Runtime.ImportModuleError
Expected Behavior
It should deploy properly and be able to GET /
Actual Behavior
When it does GET to / it 502s because of an import error
Steps to Reproduce
Use this code (api/app.py):
importosfromdotenvimportload_dotenvfromflaskimportFlask,jsonify,requestfromwaitressimportservefromapi.youtube_analyzerimportYouTubeAnalyzer
# Loadenvironmentvariablesload_dotenv()api_key=os.getenv('YOUTUBE_API_KEY')ifnot api_key:
raiseValueError("Please set YOUTUBE_API_KEY in your .env file")app=Flask(__name__)analyzer=YouTubeAnalyzer(api_key)
@app.route('/',methods=['GET'])defindex():
returnjsonify({'status': 'ok'}),200
@app.route('/analyze',methods=['GET'])defanalyze_channel():
returnjsonify({'status': 'ok'}),200if__name__=='__main__':
port=os.getenv('PORT',5000)print(f"Starting server on http://0.0.0.0:{port}")serve(app,host='0.0.0.0',port=port)
is my modular path incorrect? here's my directory structure:
so i have a folder/module called api, and inside of it a file/module called app, and inside of that i have a Flask app variable called app. so my module path should be api.app.app, right?
@zfogg try adding the package in the includes in the zappa setting. Also, from what I found it's most likely because it can't figure out what your application function is the wsgi to be exact. normally it can discover it. Try adding something like this to the zappa settings (this is at least for django):
Context
When I try to deploy or update, the process works well except for the final status check. It 502s because it can't import
handler
module, which is weird because that's generated by zappa not me.The output of
zappa tail
:Expected Behavior
It should deploy properly and be able to GET /
Actual Behavior
When it does GET to / it 502s because of an import error
Steps to Reproduce
zappa deploy dev
Your Environment
pip freeze
:zappa_settings.json
:The text was updated successfully, but these errors were encountered: