[Django]-Google app engine + python (django) deployment error: Error loading MySQLdb module

7👍

The ‘Django Support’ documentation hints at the solution, but doesn’t make it explicit:

Since the standard django.db.backends.mysql backend uses MySQLdb internally, app.yaml must reference MySQLdb in the list of libraries.

Adding the following to app.yaml seems to fix the ImportError:

libraries:
- name: MySQLdb
  version: "latest"

Note that MySQLdb is not currently included in the list of available third party libraries. I tried it on a whim and it seems to have fixed the issue for me, YMMV.enter link description here

2👍

As the Cloud SQL docs clearly state, you should be using ''google.appengine.ext.django.backends.rdbms' as your database engine setting.

0👍

If it’s not working after adding the following to your app.yaml:

libraries:
- name: MySQLdb
  version: "latest"

…then take the following steps:

  1. Ensure MySQLdb is installed pip install mysql-python on Mac
  2. Ensure the GAE devserver is pointing to your virtualenv/pip’d python 2.7 installation vs. Mac/*nix’s default version as pip may not have installed it there. I resolved Can't find module: MySQLdb by updating the GAE devserver to use: /usr/local/bin/python2.7 e.g. in GAE devserver preferences for Python Path

Note: the preferences can be accessed through the application menus:

  • If you’re using Windows: look under File > Preferences...
  • If you’re using Mac, look under GoogleAppengineLauncher > Preferences...

Leave a comment