简体   繁体   English

升级到appengine dev server 1.7.6后导入simplejson时出错

[英]Error importing simplejson after upgrading to appengine dev server 1.7.6

I just upgraded to the App Engine Python Development server version 1.7.6 on OS X, and since upgrading, I'm receiving the following error when I try to run my app: 我刚刚在OS X上升级到App Engine Python Development服务器版本1.7.6,并且自升级以来,当我尝试运行我的应用程序时收到以下错误:

ERROR    2013-04-02 04:05:14,268 wsgi.py:219] 
Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 196, 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 255, in _LoadHandler
    handler = __import__(path[0])
  File "/Users/rmorlok/Dropbox/ryanroot/ryan-projects/Development/docalytics/online/main.py", line 13, in <module>
    from google.appengine.tools import dev_appserver
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 62, in <module>
    import simplejson
ImportError: No module named simplejson

I made sure that simplejson is installed by running 我确保通过运行安装simplejson

sudo pip install simplejson

which completed successfully. 哪个成功完成。 I can successfully import simplejson if I run Python on the console and import it, but when running my app via PyCharm or the GoogleAppengineLaunch, I get the above error. 如果我在控制台上运行Python并导入它,我可以成功导入simplejson,但是当通过PyCharm或GoogleAppengineLaunch运行我的应用程序时,我得到上述错误。

Does anyone know what's going on? 有谁知道发生了什么?

SimpleJson has been renamed to Json in one of the latest versions. SimpleJson已经在最新版本中重命名为Json。 If you don't update to the latest version of simplejson you wouldn't have this problem. 如果您没有更新到simplejson的最新版本,则不会出现此问题。 So you can revert to a earlier version or you can add the following to the top of the python file that gives the problem: 所以你可以恢复到早期版本,或者你可以将以下内容添加到python文件的顶部,提出问题:

import json as simplejson

Probably Google has some requirement on the versions when you install the App Engine SDK for python. 当您为python安装App Engine SDK时,Google可能会对这些版本有一些要求。

This problem may be caused by version conflict or wrong configuration of sys.path. 此问题可能是由版本冲突或sys.path的错误配置引起的。 Here are some advises: 以下是一些建议:

  • Make sure you have only one version of sdk installed. 确保只安装了一个版本的sdk。 You may have two versiones installed in /usr/local/google_appengine and /Applications/GoogleAppEngineLauncher.app/ 您可以在/usr/local/google_appengine/Applications/GoogleAppEngineLauncher.app/安装两个版本
  • After you reinstalled your appengine, run appengine launcher in /Applications/GoogleAppEngineLauncher.app/ by default it creates a symlink in /usr/local/google_appengine When symlink is created, check permissions and make sure your system variables are set up as needed, this topic could be helpful Configuring App Engine path for PyDev on Mac 重新安装appengine后,在/Applications/GoogleAppEngineLauncher.app/运行appengine启动器,默认情况下会在/usr/local/google_appengine中创建符号链接创建符号链接时,检查权限并确保根据需要设置系统变量,主题可能有用在Mac上为PyDev配置App Engine路径
  • When using pycharm make sure you have appegine support enabled. 使用pycharm时,请确保已启用appegine支持。
  • If you are using virtualenv make sure appengine is in sys.path. 如果您使用的是virtualenv,请确保appengine位于sys.path中。
  • You may try to add $APPENGINEPATH/lib to sys.path 您可以尝试将$ APPENGINEPATH / lib添加到sys.path
  • If this problem persists understand which server are you using dev_appserver or dev_appserver2, see details in release notes 如果此问题仍然存在,请了解您使用dev_appserver或dev_appserver2的服务器,请参阅发行说明中的详细信息

If nothing helps you need to dig deeper. 如果没有什么帮助你需要深入挖掘。 For our purposes we have customized version of launcher in our project(to avoid some staff which appengine sdk stubs in standard library). 为了我们的目的,我们在我们的项目中有自定义版本的启动器(以避免一些工作人员在标准库中添加sdk存根)。 Here it is http://pastebin.com/iU2PsGhE 这是http://pastebin.com/iU2PsGhE

Environment setup is done by those steps(both: in our case and in sdk): 环境设置由这些步骤完成(两者:在我们的例子中和在sdk中):

  1. Locate appengine root directory. 找到appengine根目录。
  2. Fid DIR_PATH, which is for some reason $APPENGINEPATH/lib/ipaddr FID DIR_PATH,由于某种原因$ APPENGINEPATH / lib / ipaddr
  3. Import the right versions of third party libraries located in $APPENGINEPATH/lib/ 导入位于$ APPENGINEPATH / lib /中的正确版本的第三方库

If nothing above helps feel free to comment this answer, we will find a solution. 如果上述任何内容都无法对此答案发表评论,我们将找到解决方案。

If you are using eclipse you have to pip install simplejson on the console and then reset your python interpreter. 如果你正在使用eclipse,你必须在控制台上pip install simplejson然后重置你的python解释器。 To do this you must: 要做到这一点,你必须:

  1. right click on your PyDev project and click propterties 右键单击PyDev项目并单击propterties
  2. select python interpretor/grammar on the left pane 在左窗格中选择python interpretor / grammar
  3. click the blue link that says configure interpreter 单击配置解释器的蓝色链接
  4. Click remove on the top right and then autoconfig 单击右上角的删除,然后单击autoconfig
  5. If auto config does not work manually find your python.exe inside your python installation folder 如果自动配置不起作用,请在python安装文件夹中找到python.exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM