superset: ModuleNotFoundError: No module named 'MySQLdb' getting this error while generating graph in superset 3.0.1

getting the below error in superset 3.0.1.

while trying to create graph which is throwing an error as shown below

10.81.233.11 - - [19/Oct/2023 16:56:47] “POST /superset/log/?explode=events HTTP/1.1” 200 - 10.81.233.11 - - [19/Oct/2023 16:56:47] “POST /api/v1/explore/form_data?tab_id=3 HTTP/1.1” 201 - 10.81.233.11 - - [19/Oct/2023 16:56:54] “POST /superset/log/?explode=events HTTP/1.1” 200 - Query SELECT COUNT(*) AS count FROM BI_EXPLORING.tbl_super_store ORDER BY count DESC LIMIT 1000 on schema BI_EXPLORING failed Traceback (most recent call last): File “/data/superset/venv/lib64/python3.9/site-packages/superset/connectors/sqla/models.py”, line 1214, in query df = self.database.get_df(sql, self.schema, mutator=assign_column_label) File “/data/superset/venv/lib64/python3.9/site-packages/superset/models/core.py”, line 613, in get_df data = self.db_engine_spec.fetch_data(cursor) File “/data/superset/venv/lib64/python3.9/site-packages/superset/db_engine_specs/base.py”, line 762, in fetch_data raise cls.get_dbapi_mapped_exception(ex) from ex File “/data/superset/venv/lib64/python3.9/site-packages/superset/db_engine_specs/base.py”, line 742, in fetch_data column_mutators = { File “/data/superset/venv/lib64/python3.9/site-packages/superset/db_engine_specs/base.py”, line 747, in <dictcomp> type(cls.get_sqla_column_type(cls.get_datatype(row[1]))) File “/data/superset/venv/lib64/python3.9/site-packages/superset/db_engine_specs/mysql.py”, line 244, in get_datatype import MySQLdb ModuleNotFoundError: No module named ‘MySQLdb’ 10.81.233.11 - - [19/Oct/2023 16:56:54] “POST /api/v1/chart/data?force HTTP/1.1” 400 - 10.81.233.11 - - [19/Oct/2023 16:56:55] “GET /api/v1/chart/0 HTTP/1.1” 404 - 10.81.233.11 - - [19/Oct/2023 16:56:55] “PUT /api/v1/explore/form_data/VQJQE7sdjQfLCk4R7DIvFrRCwH_ohXl-4KlM_4cHiI3gl0rx-iI5dlM0n02XdzVH?tab_id=3 HTTP/1.1” 200 - 10.81.233.11 - - [19/Oct/2023 16:56:55] “POST /superset/log/?explode=events HTTP/1.1” 200 - 10.81.233.11 - - [19/Oct/2023 16:57:19] “GET /api/v1/me/ HTTP/1.1” 200 - 10.81.233.11 - - [19/Oct/2023 16:57:37] “GET /api/v1/me/ HTTP/1.1” 200 -

losing confidence in superset…

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Try using the following commands:

apt update && apt install -y pkg-config libmysqlclient-dev
pip install mysqlclient
mysqlclient requires pkg-config to compile.

I’m posting this because someday someone might need it.

I also faced the same issue. I tried the following commands and its solved my issue.

sudo apt-get install libmysqlclient-dev

Once installed try installing the mysqlclient in the python virtual env where superset is installed

pip install mysqlclient