1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Google App Engine Flexible environment for Python with Flask and Gunicorn

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I used to have a setup for my google app engine python project with the following app.yaml:

    runtime: python
    env: flex
    entrypoint: gunicorn -b :$PORT main:app

    runtime_config:
    python_version: 3

    resources:
    cpu: 1
    memory_gb: 2.3
    disk_size_gb: 10
    volumes:
    - name: ramdisk1
    volume_type: tmpfs
    size_gb: 0.5

    manual_scaling:
    instances: 1


    And a requirements.txt that looks like this:

    Flask==0.12.2
    gunicorn==19.7.1
    numpy==1.8.0
    scipy==1.5.3
    mysql-connector-python==8.0.23



    But Google made it so you can no longer deploy using python version 3, now instead the app.yaml file must look like this or something similar:

    runtime_config:
    operating_system: "ubuntu22"
    runtime_version: "3.12"



    This makes my requirements.txt not work and I keep changing it, my latest version is this:

    Flask==2.0.3
    gunicorn==22.0.0
    numpy==2.1.1
    scipy==1.14.0
    mysql-connector-python==9.0.0
    Jinja2==3.1.1
    MarkupSafe==2.1.1
    Werkzeug==2.0.3


    No matter how much I change it or what versions I change for these libraries, I always get some sort of error whether it be gunicorn, flask, Werkzeug, or Jinja2.

    This latest version gives me an error when trying to deploying with gcloud app deploy: ImportError: cannot import name 'Markup' from 'jinja2' (/layers/google.python.pip/pip/lib/python3.11/site-packages/jinja2/init.py). I also use Python 3.10 instead of 3.12 since it seems to give me more errors.

    If anyone can give me a requirements.txt that works with gunicorn and Flask with a python version that can still be deployed that would be most appreciated.

    Continue reading...

Compartilhe esta Página