GAE上500服务器错误 - 未加载MySQLdb

时间:2014-10-15 04:23:56

标签: python django google-app-engine mysql-python

我在GAE上传我的应用时出现500服务器错误。使用带有SETTINGS_MODE =' prod'的dev_appserver在本地工作得很好。

根据日志,它无法在GAE上找到MySQLdb。这对我没有意义。

帮助!

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 266, in Handle
    result = handler(dict(self._environ), self._StartResponse)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/core/handlers/wsgi.py", line 236, in __call__
    self.load_middleware()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/core/handlers/base.py", line 49, in load_middleware
    mod = import_module(mw_module)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/contrib/auth/middleware.py", line 3, in <module>
    from django.contrib.auth.backends import RemoteUserBackend
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/contrib/auth/backends.py", line 3, in <module>
    from django.contrib.auth.models import Permission
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/contrib/auth/models.py", line 8, in <module>
    from django.db import models
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/utils.py", line 93, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/utils.py", line 27, in load_backend
    return import_module('.base', backend_name)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/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 MySQLdb

1 个答案:

答案 0 :(得分:0)

答案很简单。在app.yaml文件中添加以下行:

库: - 名称:MySQLdb   版本:&#34;最新&#34;

详情可在页面上找到

https://cloud.google.com/appengine/docs/python/cloud-sql