airflow-tutorial icon indicating copy to clipboard operation
airflow-tutorial copied to clipboard

webserver_1 | NameError: name '_mysql' is not defined

Open prajwollamichhane11 opened this issue 2 years ago • 14 comments

webserver_1 | NameError: name '_mysql' is not defined

prajwollamichhane11 avatar Oct 06 '21 10:10 prajwollamichhane11

Same thing. is this issue solved already?

rjimpervious avatar Oct 10 '21 17:10 rjimpervious

I have this same issue.

I have mySQL 8.0.26, Postgres 12, Kubernetes and SQLite. I installed those packages manually and still have this issue.

I have used mySQL for other projects before and never got this issue, however I'm a novice at using Docker containers.

acemasterjb avatar Oct 14 '21 18:10 acemasterjb

I followed the instructions on a separate issue (linked below) and they helped me with the _msql issue.

Roughly the fix was making sure apache-airflow was installed, updating the puckel/docker-airflow from version 1.10.1 to 1.10.9, and updating sqlalchemy from 1.2.0 to 1.3.0. The exact docker-compose-yml is available in the comment linked below.

https://github.com/tuanavu/airflow-tutorial/issues/51#issuecomment-901978083

sophiaxc avatar Oct 18 '21 17:10 sophiaxc

I followed the instructions on a separate issue (linked below) and they helped me with the _msql issue.

Roughly the fix was making sure apache-airflow was installed, updating the puckel/docker-airflow from version 1.10.1 to 1.10.9, and updating sqlalchemy from 1.2.0 to 1.3.0. The exact docker-compose-yml is available in the comment linked below.

#51 (comment)

correct, this https://github.com/tuanavu/airflow-tutorial/issues/51#issuecomment-901978083 as well as this https://github.com/tuanavu/airflow-tutorial/issues/52#issue-983640986 are the same fixes to the same issue.

In case @tuanavu is still around, you can probable close these two issues after updating that docker-compose file.

acemasterjb avatar Oct 18 '21 18:10 acemasterjb

I'm still having this issue even though I have made the following updates:

image: puckel/docker-airflow:1.10.9
   PYTHON_DEPS: sqlalchemy==1.3.0

Are those the only two things to update? I also have apache-airflow installed. I'm running docker-compose up from the terminal within VS code - is that the correct approach? Do I need to install mySQL?

LucyAFH avatar Jan 19 '22 15:01 LucyAFH

I'm also facing the same issue ...I have used the docker-compose-yml file in this thread and followed the instructions under "Getting Started" . Has anyone managed to solve it Error ?

yihuiteh avatar Jan 21 '22 10:01 yihuiteh

Upgrading docker compose worked for me. If you look at https://github.com/puckel/docker-airflow, they state that docker-compose 1.29.1 is required. I had 1.29.0, and upgraded and that fixed the problem.

I then ran into the wtforms issue, which is solved by explicitly putting wtforms 2.3.3 in the docker-compose.yml file.

dpmcgonigle avatar Feb 11 '22 19:02 dpmcgonigle

I was having the same _mysql is not defined error as above so I updated the docker-compose.yml file as mentioned above. It fixed the mysql issue but another one came up...ImportError: cannot import name 'soft_unicode' from 'markupsafe', I noticed the python version running is now 3.7 instead of python3.6 from before the .yml file update. Did anyone encounter this as well and how did you fix the issue?

I have the following: Docker version 20.10.12, build e91ed57 docker-compose version 1.29.2, build 5becea4c Airflow 2.2.3

image

chiqui-m avatar Feb 21 '22 17:02 chiqui-m

I was having the same _mysql is not defined error as above so I updated the docker-compose.yml file as mentioned above. It fixed the mysql issue but another one came up...ImportError: cannot import name 'soft_unicode' from 'markupsafe', I noticed the python version running is now 3.7 instead of python3.6 from before the .yml file update. Did anyone encounter this as well and how did you fix the issue?

I have the following: Docker version 20.10.12, build e91ed57 docker-compose version 1.29.2, build 5becea4c Airflow 2.2.3

image

Fo fix this issue, please add:

PYTHON_DEPS: sqlalchemy==1.3.0 markupsafe==2.0.1 wtforms==2.2

Works for me.

All the best!

neemiasbsilva avatar Mar 01 '22 19:03 neemiasbsilva

I can confirm this!

Be careful to change 1.10.1 to 1.10.9 at both positions

[...]
webserver:
    image: puckel/docker-airflow:1.10.9
    build:
      context: https://github.com/puckel/docker-airflow.git#1.10.9
      dockerfile: Dockerfile
      args:
        AIRFLOW_DEPS: gcp_api,s3
        PYTHON_DEPS: sqlalchemy==1.3.0 markupsafe==2.0.1 wtforms==2.2
[...]

Docker version 20.10.7, docker-compose version 1.29.2

ronnyworm avatar Mar 11 '22 19:03 ronnyworm

image

Help! I'm still having a soft_unicode import error from markupsafe with Jinja2. Did a downgrade to markupsafe 2.0.1, updated the yml file but still facing the same issue.

dargo94 avatar Apr 17 '22 10:04 dargo94

I am getting the same error: ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/init.py) Traceback (most recent call last): File "/usr/local/bin/airflow", line 25, in from airflow.configuration import conf File "/usr/local/lib/python3.7/site-packages/airflow/init.py", line 42, in from airflow.models import DAG File "/usr/local/lib/python3.7/site-packages/airflow/models/init.py", line 21, in from airflow.models.baseoperator import BaseOperator, BaseOperatorLink # noqa: F401 File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 36, in import jinja2 File "/usr/local/lib/python3.7/site-packages/jinja2/init.py", line 33, in from jinja2.environment import Environment, Template File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in from jinja2 import nodes File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in from jinja2.utils import Markup File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in from markupsafe import Markup, escape, soft_unicode ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/init.py)

oauthtester01 avatar May 18 '22 17:05 oauthtester01

Hi, thanks for the recommendations. I have combined two cases to solve this problem after reading your instructions, you can just follow them here.

If you encountered the _mysql problem, please don't forget to download apache-airflow using the keywords "pip install apache-airflow" or depending on the terminal you're using.

After that update the docker-compose.yml file from the cloned repository.

version: '3' services: postgres: image: postgres:9.6 environment: - POSTGRES_USER=airflow - POSTGRES_PASSWORD=airflow - POSTGRES_DB=airflow ports: - "5432:5432"

webserver: image: puckel/docker-airflow:1.10.9 build: context: https://github.com/puckel/docker-airflow.git#1.10.9 dockerfile: Dockerfile args: AIRFLOW_DEPS: gcp_api,s3 PYTHON_DEPS: sqlalchemy==1.3.0 markupsafe==2.0.1 wtforms==2.2 restart: always depends_on: - postgres environment: - LOAD_EX=n - EXECUTOR=Local - FERNET_KEY=jsDPRErfv8Z_eVTnGfF8ywd19j4pyqE3NpdUBA_oRTo= volumes: - ./examples/intro-example/dags:/usr/local/airflow/dags # Uncomment to include custom plugins # - ./plugins:/usr/local/airflow/plugins ports: - "8080:8080" command: webserver healthcheck: test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"] interval: 30s timeout: 30s retries: 3

After this, don't forget to close the terminal first, save the .yml file and open the terminal again. Just to be sure HAHA. Then go to the folder again in the terminal. Use the command "docker-compose up -d --build" first before you use the command "docker-compose up"

It works 100%

jedbites avatar Sep 05 '22 07:09 jedbites

Hi, thanks for the recommendations. I have combined two cases to solve this problem after reading your instructions, you can just follow them here.

If you encountered the _mysql problem, please don't forget to download apache-airflow using the keywords "pip install apache-airflow" or depending on the terminal you're using.

After that update the docker-compose.yml file from the cloned repository.

version: '3' services: postgres: image: postgres:9.6 environment: - POSTGRES_USER=airflow - POSTGRES_PASSWORD=airflow - POSTGRES_DB=airflow ports: - "5432:5432"

webserver: image: puckel/docker-airflow:1.10.9 build: context: https://github.com/puckel/docker-airflow.git#1.10.9 dockerfile: Dockerfile args: AIRFLOW_DEPS: gcp_api,s3 PYTHON_DEPS: sqlalchemy==1.3.0 markupsafe==2.0.1 wtforms==2.2 restart: always depends_on: - postgres environment: - LOAD_EX=n - EXECUTOR=Local - FERNET_KEY=jsDPRErfv8Z_eVTnGfF8ywd19j4pyqE3NpdUBA_oRTo= volumes: - ./examples/intro-example/dags:/usr/local/airflow/dags # Uncomment to include custom plugins # - ./plugins:/usr/local/airflow/plugins ports: - "8080:8080" command: webserver healthcheck: test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"] interval: 30s timeout: 30s retries: 3

After this, don't forget to close the terminal first, save the .yml file and open the terminal again. Just to be sure HAHA. Then go to the folder again in the terminal. Use the command "docker-compose up -d --build" first before you use the command "docker-compose up"

It works 100%

Worked for me, thanks, maintain the indentation.

SDcodehub avatar Sep 28 '22 09:09 SDcodehub