更新:这是我在全新安装的 OS X 10.8.3 上使用 1.8.0 App Engine SDK 时遇到的问题。
首先 - 关于 SO 有很多类似标题的问题。我已经检查过了,我不相信他们会回答我的问题。大多数情况下,他们建议获取 libsqlite3-dev 并重建 python 以获取 _sqlite3.so,但这已经是它应该在的地方:
$ 查找 / -name _sqlite3.so 密码: ... /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/_sqlite3.so /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_sqlite3.so /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
导致应用引擎 SDK 尝试加载该模块的实际代码是:
remaining = TaskSetElement.all().filter('taskSet', ts_key).filter('complete', False).count()
这是 SDK 堆栈跟踪:
File "~/dev/myApp/myApp/task.py", line 90, in completeTaskSetElement
remaining = TaskSetElement.all().filter('taskSet', ts_key).filter('complete', False).count()
File "~/dev/GAE/google_appengine/google/appengine/ext/db/__init__.py", line 2133, in count
result = raw_query.Count(limit=limit, **kwargs)
File "~/dev/GAE/google_appengine/google/appengine/api/datastore.py", line 1698, in Count
batch = self.GetBatcher(config=config).next()
File "~/dev/GAE/google_appengine/google/appengine/datastore/datastore_query.py", line 2754, in next
return self.next_batch(self.AT_LEAST_ONE)
File "~/dev/GAE/google_appengine/google/appengine/datastore/datastore_query.py", line 2791, in next_batch
batch = self.__next_batch.get_result()
File "~/dev/GAE/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 604, in get_result
return self.__get_result_hook(self)
File "/Users/colin/dev/GAE/google_appengine/google/appengine/datastore/datastore_query.py", line 2528, in __query_result_hook
self._batch_shared.conn.check_rpc_success(rpc)
File "~/dev/GAE/google_appengine/google/appengine/datastore/datastore_rpc.py", line 1222, in check_rpc_success
rpc.check_success()
File "~/dev/GAE/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 570, in check_success
self.__rpc.CheckSuccess()
File "/Users/colin/dev/GAE/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
self.request, self.response)
File "~/dev/GAE/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall
self._MakeRealSyncCall(service, call, request, response)
File "~/dev/GAE/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 234, in _MakeRealSyncCall
raise pickle.loads(response_pb.exception())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1382, in loads
return Unpickler(file).load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 858, in load
dispatch[key](self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1090, in load_global
klass = self.find_class(module, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1124, in find_class
__import__(module)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in
from dbapi2 import *
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 27, in
from _sqlite3 import *
File "~/dev/GAE/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 856, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named _sqlite3
在此行之前,我有一堆数据存储区代码执行得很好。我直接从命令行或在 Eclipse 中使用 pydev 运行 dev_appserver.py 时遇到了同样的问题。
从命令行,一切看起来都不错:
$蟒蛇 Python 2.7.2(默认,2012 年 10 月 11 日,20:14:37) [GCC 4.2.1 兼容 Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 在 darwin 输入“帮助”、“版权”、“信用”或“许可”以获取更多信息。 >>> 导入 sqlite3 >>> 导入 _sqlite3 >>> 导入系统 >>> 打印(系统路径) ['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat -mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7 /Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7 /lib/python2.7/lib-old','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload','/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages'] >>>
此代码片段(在应用引擎 SDK 中运行)从等式中删除了应用引擎数据存储区代码:
...
logging.info("Python Version: %s" % sys.version)
logging.info(filter(lambda p: 'lib-dynload' in p, sys.path))
import sqlite3
...
它输出这个:
INFO 2013-05-26 05:55:12,055 main.py:38] Python 版本:2.7.2(默认,2012 年 10 月 11 日,20:14:37) [GCC 4.2.1 兼容 Apple Clang 4.0 (tags/Apple/clang-418.0.60)] 信息 2013-05-26 05:55:12,055 main.py:40] ['/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload'] 错误 2013-05-26 05:55:12,058 cgi.py:121] Traceback(最近一次通话最后一次): 文件“main.py”,第 42 行,在 导入 sqlite3 文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py”,第 24 行,在 从 dbapi2 导入 * 文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py”,第 27 行,在 从 _sqlite3 导入 * 文件“~/dev/GAE/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py”,第 856 行,在 load_module raise ImportError('No module named %s' % fullname) ImportError:没有名为 _sqlite3 的模块
任何想法是什么问题?谢谢,
科林