1

I am using googleAppEngineLauncher to try mysql connection.

It gives the log

 File "/Users/kakshilshah/Desktop/hope/skeduleBackend/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Users/kakshilshah/Desktop/hope/skeduleBackend/django/db/backends/mysql/base.py", line 17, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: No module named _mysql

I have done pip install MySQL-python

Even commands like python manage.py dbshell works, and connects me to the cloudsql backend.

I can access all the tables there.

But, running it gives the same error.

I have mysql 5.6 installed.

Adding the following to app.yaml

- name: MySQLdb
  version: "latest"

also does not help, because I checked the libraries directory and there was no mysqldb.

My settings -

import os

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
            'HOST': '173.194.xxx.xxx',
            'NAME': 'my_database',
            'USER': 'root',
            'PASSWORD': 'xxxxxxxx',
    }
}
Sven
  • 98,649
  • 14
  • 180
  • 226
Kakshil Shah
  • 111
  • 6

2 Answers2

1

If you installed MySQL-Python via pip it probably failed at building '_mysql' extension, which is the C extension and requires MSVC++ 9.0 to build:

building '_mysql' extension

error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27

On Windows your best solution is to just use a binary installer for MySQL-python such as http://sourceforge.net/projects/mysql-python. You can download the MSVC++ Compiler for Python if you want, but you will also need to install the MySQL developer build including the C headers and libraries and may run into other problems.

This only matters for running the app locally on the development server of course, as the App Engine Python runtime already includes MySQLdb on the remote environment where you deploy your app.

Adam
  • 868
  • 5
  • 12
  • I am talking about deployment only. It gives this error - http://stackoverflow.com/questions/30015930/python-pip-install-fails-could-not-build-the-egg-also-cannot-use-1-2-5-becaus – Kakshil Shah May 04 '15 at 04:08
1

If you are like me and are using an Ubuntu server with Python 3.5 I just had a gut-wrenching few hours trying to solve this one. The apache server wouldn't start using the wsgi setup I had going through my virtualenv.

So I tried it all, pip install this and pip install that. So FYI for Python 3.5 you need to have the pip library mysqlclient installed to connect to mysql through python and django. However I kept getting the same error you were... In the end what I did was run: easy_install mysqlclient simple as that, I believe I was missing some dependency that easy_install got and installed in one blow.

Good luck, hope it helps you, or someone else who found this page looking for light at the end of the tunnel.

Artisan
  • 111
  • 2