[19.04] no module named MySQLdb

Bug #1834614 reported by Andrew McLeod
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard Charm
Fix Released
High
James Page

Bug Description

shared-db-relation-changed fails due to missing module MySQLdb

the error suggests installing mysqlclient or mysql-python but these both fail with this error:

fix is to pip install mysqlclient or mysql-python, but these both fail with:

    Complete output from command python setup.py egg_info:
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-945ue9jv/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-945ue9jv/mysqlclient/setup_posix.py", line 51, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-945ue9jv/mysqlclient/setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    OSError: mysql_config not found

which can be resolved with:

sudo apt install libmysqlclient-dev

and then installing python3-pip to install mysqlclient allows the hook to complete successfully

unit-openstack-dashboard-0: 09:03:30 DEBUG unit.openstack-dashboard/0.shared-db-relation-changed File "/usr/lib/python3/dist-packages/django/db/backends/mysql/base.py", line 26, in <module>
unit-openstack-dashboard-0: 09:03:30 DEBUG unit.openstack-dashboard/0.shared-db-relation-changed import MySQLdb as Database
unit-openstack-dashboard-0: 09:03:30 DEBUG unit.openstack-dashboard/0.shared-db-relation-changed ModuleNotFoundError: No module named 'MySQLdb'

Revision history for this message
James Page (james-page) wrote :

openstack release version would be useful here - there where changes to the default dialect in sqlalchemy at stein so this might be related to bug 1832075

Revision history for this message
James Page (james-page) wrote :

(ftr pip installs generally just create issues later on with upgrades - python-pymsql or python-mysqldb provide the two dialects for MySQL that sqlalchemy supports)

Changed in charm-openstack-dashboard:
status: New → Incomplete
Revision history for this message
Andrew McLeod (admcleod) wrote :

This testing was disco-stein

Revision history for this message
James Page (james-page) wrote :

At disco the patches to default to pymysql for the django mysql driver where dropped; so the app is looking for mysqldb rather than pymysql.

This is not configurable - the only way to force pymysql is this hack:

  https://stackoverflow.com/questions/34777755/how-to-config-django-using-pymysql-as-driver

so we might just be better to install python3-mysqldb to fix this issue. Horizon is not eventlet dependent so some of the benefits of using pymysql are not so valuable.

Revision history for this message
James Page (james-page) wrote :
Changed in charm-openstack-dashboard:
status: Incomplete → In Progress
importance: Undecided → High
assignee: nobody → James Page (james-page)
milestone: none → 19.07
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-openstack-dashboard (master)

Reviewed: https://review.opendev.org/672074
Committed: https://git.openstack.org/cgit/openstack/charm-openstack-dashboard/commit/?id=ae19450b01a529ba353e7fce4dbfa722c62127f4
Submitter: Zuul
Branch: master

commit ae19450b01a529ba353e7fce4dbfa722c62127f4
Author: James Page <email address hidden>
Date: Mon Jul 22 16:37:08 2019 +0100

    stein: Ensure mysqldb driver is installed

    The default MySQL dialect for Django in Ubuntu Disco or later
    switch back to mysqldb rather than pymysql; ensure that required
    driver is installed for stein or later.

    Change-Id: Ib03353d12d38b5a5ef1bac820470636c886ec8dc
    Closes-Bug: 1834614

Changed in charm-openstack-dashboard:
status: In Progress → Fix Committed
David Ames (thedac)
Changed in charm-openstack-dashboard:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.