Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webserver_1 | NameError: name '_mysql' is not defined #54

Open
prajwollamichhane11 opened this issue Oct 6, 2021 · 14 comments
Open

webserver_1 | NameError: name '_mysql' is not defined #54

prajwollamichhane11 opened this issue Oct 6, 2021 · 14 comments

Comments

@prajwollamichhane11
Copy link

webserver_1 | NameError: name '_mysql' is not defined

@rjimpervious
Copy link

Same thing. is this issue solved already?

@acemasterjb
Copy link

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.

@sophiaxc
Copy link

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)

@acemasterjb
Copy link

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 #51 (comment) as well as this #52 (comment) 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.

@LucyAFH
Copy link

LucyAFH commented Jan 19, 2022

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?

@yihuiteh
Copy link

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
?

@dpmcgonigle
Copy link

dpmcgonigle commented Feb 11, 2022

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.

@chiqui-m
Copy link

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

@neemiasbsilva
Copy link

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!

@ronnyworm
Copy link

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

@dargo94
Copy link

dargo94 commented Apr 17, 2022

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.

@oauthtester01
Copy link

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)

@jedbites
Copy link

jedbites commented Sep 5, 2022

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%

@SDcodehub
Copy link

SDcodehub commented Sep 28, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests