Error importing simplejson after upgrading to appe

2019-07-07 08:07发布

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:

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

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.

Does anyone know what's going on?

3条回答
ら.Afraid
2楼-- · 2019-07-07 08:36

If you are using eclipse you have to pip install simplejson on the console and then reset your python interpreter. To do this you must:

  1. right click on your PyDev project and click propterties
  2. select python interpretor/grammar on the left pane
  3. click the blue link that says configure interpreter
  4. Click remove on the top right and then autoconfig
  5. If auto config does not work manually find your python.exe inside your python installation folder
查看更多
混吃等死
3楼-- · 2019-07-07 08:50

SimpleJson has been renamed to Json in one of the latest versions. If you don't update to the latest version of simplejson you wouldn't have this problem. 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:

import json as simplejson

Probably Google has some requirement on the versions when you install the App Engine SDK for python.

查看更多
Emotional °昔
4楼-- · 2019-07-07 08:55

This problem may be caused by version conflict or wrong configuration of sys.path. Here are some advises:

  • Make sure you have only one version of sdk installed. You may have two versiones installed in /usr/local/google_appengine and /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
  • When using pycharm make sure you have appegine support enabled.
  • If you are using virtualenv make sure appengine is in sys.path.
  • You may try to add $APPENGINEPATH/lib to sys.path
  • If this problem persists understand which server are you using dev_appserver or dev_appserver2, see details in release notes

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). Here it is http://pastebin.com/iU2PsGhE

Environment setup is done by those steps(both: in our case and in sdk):

  1. Locate appengine root directory.
  2. Fid DIR_PATH, which is for some reason $APPENGINEPATH/lib/ipaddr
  3. Import the right versions of third party libraries located in $APPENGINEPATH/lib/

If nothing above helps feel free to comment this answer, we will find a solution.

查看更多
登录 后发表回答