【问题标题】:Using MySQL with dev_appserver (Google App Engine) and Google SQL Service将 MySQL 与 dev_appserver (Google App Engine) 和 Google SQL 服务一起使用
【发布时间】:2011-11-15 04:48:28
【问题描述】:

我正在使用 Google App Engine 和 Google SQL 服务,并希望使用该选项

dev_appserver.py --mysql_user=username myapp

为了将本地 MySQL 数据库用于开发目的,以及在 prod 环境中使用 SQL 服务。

我已安装并运行 MySQLdb:

/usr/bin>>python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> 

但是,当我运行 dev_appserver 命令时,我收到以下错误:

zipimporter('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg', 'MySQLdb/')
ERROR    2011-09-12 09:34:53,541 rdbms_mysqldb.py:90] The rdbms API is not available because the MySQLdb library could not be loaded.

我已验证 MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg 位于 (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site -packages/) 并且它是可访问的。

知道是什么导致了这个错误吗?

下面提供了完整的堆栈跟踪以供参考:

/Users/eddieboyd>>dev_appserver.py --debug --mysql_user=mysql  eddiehelloworld
Warning: You are using a Python runtime (2.7) that is more recent than the production runtime environment (2.5). Your application may use features that are not available in the production environment and may not work correctly when deployed to production.
INFO     2011-09-12 09:34:53,290 appengine_rpc.py:159] Server: appengine.google.com
INFO     2011-09-12 09:34:53,304 appcfg.py:449] Checking for updates to the SDK.
DEBUG    2011-09-12 09:34:53,305 appengine_rpc.py:364] Sending HTTPS request:
POST /api/updatecheck?release=1.5.3&timestamp=1311108376&api_versions=%5B%271%27%5D HTTPS/1.1
Host: appengine.google.com
X-appcfg-api-version: 1
Content-type: application/octet-stream
User-agent: appcfg_py/1.5.3 Darwin/10.8.0 Python/2.7.2.final.0


INFO     2011-09-12 09:34:53,465 appcfg.py:466] The SDK is up to date.
WARNING  2011-09-12 09:34:53,465 datastore_file_stub.py:512] Could not read datastore data from /var/folders/++/++71vE++6+0++4RjPqRgNE+0Eyo/-Tmp-/dev_appserver.datastore
INFO     2011-09-12 09:34:53,478 py_zipimport.py:148] zipimporter('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg', 'MySQLdb/')
ERROR    2011-09-12 09:34:53,541 rdbms_mysqldb.py:90] The rdbms API is not available because the MySQLdb library could not be loaded.
ERROR    2011-09-12 09:34:53,541 dev_appserver_main.py:638] <type 'exceptions.NotImplementedError'>: Unable to find the MySQLdb library. Please see the SDK documentation for installation instructions.
DEBUG    2011-09-12 09:34:53,543 dev_appserver_main.py:640] Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_main.py", line 635, in main
    dev_appserver.SetupStubs(appinfo.application, **option_dict)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 4668, in SetupStubs
    rdbms_mysqldb.connect(database='')
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/rdbms_mysqldb.py", line 96, in connect
    'Unable to find the MySQLdb library. Please see the SDK '
NotImplementedError: Unable to find the MySQLdb library. Please see the SDK documentation for installation instructions.

【问题讨论】:

  • 我找到了分步教程here

标签: mysql google-app-engine


【解决方案1】:

穷人的解决方案。

我加了

"导入 MySQLdb"

在 dev_appserver.py 中。

现在可以了。

【讨论】:

  • 我已将此添加到我的 bash_profile 中。这为命令行修复了它,但不适用于 AppEngineLauncher:export DYLD_LIBRARY_PATH=/usr/local/mysql/lib 我通过制作符号链接修复了它:sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
【解决方案2】:

确保使用AppEngine SDK 的最新版本,当前版本为 1.6.2。

之后安装python mysql支持包:python-mysqldb。

【讨论】:

    【解决方案3】:

    也许您的系统没有所需的 MySQL 模块。在 Fedora 16 64 位上,我通过安装 MySQL python 模块解决了这个问题:

    yum install MySQL-python
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-15
      • 1970-01-01
      • 2013-10-27
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 2014-06-07
      • 2012-02-26
      相关资源
      最近更新 更多