pythongoogle-app-enginepyamfapp-engine-patch

app-engine-patch with pyamf = No module named encoding


I'm trying to use app-engine-patch with pyamf by following this: http://pyamf.org/wiki/GoogleAppEngine because I want to migrate my Django <-> pyamf application to app-engine-patch <-> pyamf.

What I have now is that I created my gateway.py with only one line of code:

import pyamf

just to test can I use pyamf and I get blank page when I point my browser to that url/file so that looks good (no import problems and pyamf is found) but in the command prompt where I started server with "manage.py runserver" I see bunch of errors like:

...
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2238, in Dispatch
    self._module_dict)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2156, in ExecuteCGI
    reset_modules = exec_script(handler_path, cgi_path, hook)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2052, in ExecuteOrImportScript
    exec module_code in script_module.__dict__
  File "C:\Users\[my app-engine-patch application path]\common\appenginepatch\main.py", line 16, in <module>
    patch_all()
  File "C:\Users\[my app-engine-patch application path]\common\appenginepatch\appenginepatcher\patch.py", line 29, in patch_all
    patch_app_engine()
  File "C:\Users\[my app-engine-patch application path]\common\appenginepatch\appenginepatcher\patch.py", line 193, in patch_app_engine
    from django.utils.encoding import force_unicode, smart_str
ImportError: No module named encoding

Are there any pyamf <-> app-engine-patch gurus out there which can give me a hint what am I doing wrong and how can I setup pyamf to work with app-engine-patch?


Solution

  • Are you activating Django 1.0.2 in your app engine startup code? App Engine now comes with it, but also (for backwards compatibility) with 0.9.6, and (still for backwards compatibility) 0.9.6 is what it defaults to -- all it takes to fix this is, at startup, use:

    from google.appengine.dist import use_library
    use_library('django', '1.0')
    

    and then "Subsequent attempts to import the django package will use Django 1.0.2.". You do need to install 1.0.2 with the SDK separately. See all instructions here.