gpt4 book ai didi

python - 尝试访问 sdk 数据存储管理时出现导入错误

转载 作者:行者123 更新时间:2023-12-01 06:12:46 25 4
gpt4 key购买 nike

尝试访问开发服务器上的数据存储管理时,出现“ImportError:没有名为 simplejson 的模块”。

第一次收到此错误后,我从 slackbuilds 安装了 simplejson 包(我在 Slackware 上)。它似乎工作正常,我可以在 python 控制台上导入 simplejson 模块,没有错误。

但是当我尝试访问数据存储管理时,即使安装了模块,导入错误仍然存​​在。重新启动开发服务器没有执行任何操作。

可能出了什么问题?

编辑:这是堆栈跟踪:

Traceback (most recent call last):
File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 3245, in _HandleRequest self._Dispatch(dispatcher, self.rfile, outfile, env_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 3186, in _Dispatch base_env_dict=env_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 531, in Dispatch base_env_dict=base_env_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 2410, in Dispatch self._module_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 2320, in ExecuteCGI reset_modules = exec_script(handler_path, cgi_path, hook) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 2216, in ExecuteOrImportScript exec module_code in script_module.dict File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/main.py", line 30, in from google.appengine.ext.datastore_admin import copy_handler File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1945, in load_module return self.FindAndLoadModule(submodule, fullname, search_path) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1847, in FindAndLoadModule description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1798, in LoadModuleRestricted description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/copy_handler.py", line 40, in from google.appengine.ext.datastore_admin import utils File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1945, in load_module return self.FindAndLoadModule(submodule, fullname, search_path) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1847, in FindAndLoadModule description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1798, in LoadModuleRestricted description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/utils.py", line 35, in from google.appengine.ext.mapreduce import control File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1945, in load_module return self.FindAndLoadModule(submodule, fullname, search_path) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1847, in FindAndLoadModule description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1798, in LoadModuleRestricted description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/mapreduce/control.py", line 26, in from google.appengine.ext.mapreduce import handlers File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1945, in load_module return self.FindAndLoadModule(submodule, fullname, search_path) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1847, in FindAndLoadModule description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1295, in Decorate return func(self, *args, **kwargs) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py", line 1798, in LoadModuleRestricted description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/mapreduce/handlers.py", line 26, in import simplejson ImportError: No module named simplejson

最佳答案

使用from django.utils import simplejson

dev_appserver 模仿生产环境。您在系统级别安装的任何内容都无法导入到脚本中,以避免导入在测试中正常工作,然后在部署时严重失败。但是,您不需要捆绑这个特定的模块,因为它已经在生产环境中安装的 django 包中可用(并且带有 SDK)。

一般来说,您确实需要在应用程序目录中包含外部库,尽管您可以从其安装位置对它们进行符号链接(symbolic link),并且它们通常会正常工作(并且在部署时将部署到生产环境)。

关于python - 尝试访问 sdk 数据存储管理时出现导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4839749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com