2011-09-12 71 views
10

我使用谷歌應用程序引擎和谷歌SQL服務,並想使用的選項使用MySQL與dev_appserver(谷歌應用程序引擎)和

dev_appserver.py --mysql_user =用戶名MYAPP

谷歌SQL服務

爲了使用本地MySQL數據庫用於開發目的,以及SQL服務在prod環境中。

我有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. 
+0

我發現了一步一步的教程[這裏](http://howto.pui.ch/post/39245389801/tutorial -django-on-appengine-using-google-cloud-sql) –

回答

3

窮人的解決方案。

我加

「進口MySQLdb的」

在dev_appserver.py

它現在有效。

+0

我已將此添加到我的bash_profile。這固定它的命令行,但不是AppEngineLauncher: '出口DYLD_LIBRARY_PATH =在/ usr /本地/ mysql /下lib' 我固定它通過使符號鏈接: '須藤LN -s在/ usr /本地/ MySQL的/ lib/libmysqlclient.18.dylib/usr/lib/libmysqlclient.18.dylib' – blackjack75

1

確保使用最新版本的AppEngine SDK,該版本目前是版本1.6.2。

然後安裝python mysql支持包:python-mysqldb。

0

也許你的系統沒有所需的MySQL模塊。在Fedora 16個64位,我解決了這個通過安裝MySQL的Python模塊:

yum install MySQL-python