Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.21k forks source link

ImportError: cannot import name 'Flask' from 'flask' (unknown location) #2233

Open Shubham-Kumar-2000 opened 2 years ago

Shubham-Kumar-2000 commented 2 years ago

I am trying to deploy a simple application using zappa which uses flask and moviepy.

Context

Neither the name of the folder nor the any file is named as flask. Locally python ./app.py is just working fine. I am running on python 3.9

Expected Behavior

To run normally on lambda.

Actual Behavior

When trying to do zappa deploy every thing works fine except it ends with a 502. Then when tried to debugged with zappa tail dev, found this :

Instancing..
[1639313514980] Failed to find library: libmysqlclient.so.18...right filename?
[1639313515099] [ERROR] ImportError: cannot import name 'Flask' from 'flask' (unknown location)
Traceback (most recent call last):
  File "/var/task/handler.py", line 657, in lambda_handler
    return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 251, in lambda_handler
    handler = cls()
  File "/var/task/handler.py", line 148, in __init__
    self.app_module = importlib.import_module(self.settings.APP_MODULE)
  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/tmp/transcripter/app.py", line 1, in <module>
    from flask import Flask, render_template, request, redirect

Steps to Reproduce

  1. zappa deploy
  2. zappa tail dev

Your Environment

And additionally I don't understand why this Failed to find library: libmysqlclient.so.18...right filename? keeps coming.

Shubham-Kumar-2000 commented 2 years ago

If I just disable the slim_handler : I get a different error :

Runtime.ImportModuleError: Unable to import module 'handler': attempted relative import with no known parent package
Traceback (most recent call last):
RobbenRibery commented 1 year ago

same error