我尝试使用本地Mysql调试google-app-engine应用程序,因为经过一些编码然后将其部署到google-app-engine,访问网站,然后从应用引擎控制台的日志中检查日志,这需要相当的很多时候并不方便。但是在我安装了Mysql和mysql-python后,总会出现问题,我查了一下互联网,有很多老帖子讨论这种类似的问题,但没有一个可以解决我的问题。
我的发展环境:
Mac 10.7.3, App-Engine 1.6.4, Python 2.7.1, Mysql 5.5.23
启动app-engine开发服务器并记录:
INFO 2012-04-18 08:45:36,212 py_zipimport.py:148] zipimporter('/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg', 'MySQLdb/')
WARNING 2012-04-18 08:45:36,350 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
INFO 2012-04-18 08:45:36,484 appengine_rpc.py:160] Server: appengine.google.com
INFO 2012-04-18 08:45:36,488 appcfg.py:582] Checking for updates to the SDK.
DEBUG 2012-04-18 08:45:36,490 appengine_rpc.py:365] Sending HTTPS request:
POST /api/updatecheck?release=1.6.4×tamp=1330713524&runtime=python27&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.6.4 Darwin/11.3.0 Python/2.7.1.final.0
INFO 2012-04-18 08:45:38,001 appcfg.py:616] This SDK release is newer than the advertised release.
INFO 2012-04-18 08:45:38,075 dev_appserver_multiprocess.py:647] Running application dev~myapp on port 8080: http://localhost:8080
INFO 2012-04-18 08:45:38,076 dev_appserver_multiprocess.py:649] Admin console is available at: http://localhost:8080/_ah/admin
访问http://localhost:8080,然后记录:
DEBUG 2012-04-18 08:48:19,608 dev_appserver.py:656] Matched "/" to CGI dispatcher with path main.app
DEBUG 2012-04-18 08:48:19,622 dev_appserver.py:1624] Executing CGI with env:
{'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_CONNECTION': 'keep-alive', '_AH_THREADSAFE': '1', 'REQUEST_ID_HASH': 'B6589FC6', 'CURRENT_VERSION_ID': '1.1', 'SERVER_SOFTWARE': 'Development/1.0', 'SCRIPT_NAME': '', 'USER_ORGANIZATION': '', 'REQUEST_METHOD': 'GET', 'HTTP_HOST': 'localhost:8080', 'PATH_INFO': '/', 'SERVER_PROTOCOL': 'HTTP/1.0', 'QUERY_STRING': '', 'TZ': 'UTC', 'USER_EMAIL': '', 'CONTENT_LENGTH': '', 'USER_ID': '', 'APPENGINE_RUNTIME': 'python27', 'APPLICATION_ID': 'dev~myapp', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3', 'SERVER_NAME': 'localhost', 'REMOTE_ADDR': '127.0.0.1', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT_LANGUAGE': 'en-us', 'SDK_VERSION': '1.6.4', 'PATH_TRANSLATED': '/Users/Dajie/Workspace/Python/myapp/main.app', 'SERVER_PORT': '8080', '_AH_ENCODED_SCRIPT_NAME': '/', 'AUTH_DOMAIN': 'gmail.com'}
WARNING 2012-04-18 08:48:19,625 py_zipimport.py:139] Can't open zipfile /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg: IOError: [Errno 13] file not accessible: '/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg'
WARNING 2012-04-18 08:48:19,626 py_zipimport.py:139] Can't open zipfile /Library/Python/2.7/site-packages/WebOb-1.2b3-py2.7.egg: IOError: [Errno 13] file not accessible: '/Library/Python/2.7/site-packages/WebOb-1.2b3-py2.7.egg'
ERROR 2012-04-18 08:48:19,863 wsgi.py:189]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 187, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 225, in _LoadHandler
handler = __import__(path[0])
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1850, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1722, in FindAndLoadModule
description)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1665, in LoadModuleRestricted
description)
File "/Users/Dajie/Workspace/Python/myapp/main.py", line 22, in <module>
import MySQLdb
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1850, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1722, in FindAndLoadModule
description)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1647, in LoadModuleRestricted
return source_file.load_module(submodule_fullname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/dist/py_zipimport.py", line 246, in load_module
submodname, is_package, fullpath, source = self._get_source(fullmodname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/dist/py_zipimport.py", line 207, in _get_source
source = self.zipfile.read(relpath.replace(os.sep, '/'))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 867, in read
return self.open(name, "r", pwd).read()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 882, in open
zef_file = open(self.filename, 'rb')
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 592, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg'
INFO 2012-04-18 08:48:19,882 dev_appserver.py:2884] "GET / HTTP/1.1" 500 -
任何人都知道如何解决这个问题,而不是很多。
答案 0 :(得分:1)
导入MySQLdb时
ImportError: dlopen(/Users/Dajie/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/Dajie/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
Reason: image not found
溶液:
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib