Skip to content

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

@Shubham-Kumar-2000

Description

@Shubham-Kumar-2000

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

  • Zappa version used: 0.54.1
  • Operating System and Python version: Windows 10 with python 3.9
  • The output of pip freeze:
certifi==2021.10.8
charset-normalizer==2.0.9
click==8.0.3
colorama==0.4.4
decorator==4.4.2
Flask==2.0.2
Flask-Cors==3.0.10
idna==3.3
imageio==2.13.3
imageio-ffmpeg==0.4.5
itsdangerous==2.0.1
Jinja2==3.0.3
MarkupSafe==2.0.1
moviepy==1.0.3
numpy==1.21.4
Pillow==8.4.0
proglog==0.1.9
requests==2.26.0
six==1.16.0
SpeechRecognition==3.8.1
tqdm==4.62.3
urllib3==1.26.7
Werkzeug==2.0.2
  • Your zappa_settings.json:
{
    "dev": {
        "app_function": "app.app",
        "profile_name": null,
        "aws_region": "ap-south-1",
        "project_name": "transcripter",
        "runtime": "python3.9",
        "s3_bucket": "zappa-e5ola6g1j",
        "slim_handler": true,
        "include": []
    }
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions