Common AppEngine bulk upload issues

Google’s documentation for AppEngine provides a very nice walkthrough for uploading and downloading data. But it doesn’t necessarily help with troubleshooting. Here are a few problems that multiple members of the class have run into and their solutions.

Often you’ll store your database models in a common file (, say) so that your bulk upload and your main code can access the same model. A common error you’ll have in this case is that importing will fail as follows:

  File "/Applications/", line 3467, in LoadConfig
    ('', 'r', imp.PY_SOURCE))
  File "", line 10, in 
    import models
ImportError: No module named models

This has to do with the PYTHONPATH environment variable. I’m guessing that because is located in another directory, Python won’t search the current directory for .py files to import modules from. So you want to set (or ideally, append onto) PYTHONPATH to have “.” or the current directory.

How that works on your system depends on your shell. For me, using bash, this worked:


I expect it’s significantly different on Windows, but a search for how to set PYTHONPATH in Windows should give you some hints.

Next, you may run into authentication errors. Uploading to, you might see an error like the following:

[INFO    ] Connecting to
[ERROR   ] Exception during authentication
Traceback (most recent call last):
 File "/Applications/", line 3063, in Run
 File "/Applications/", line 1148, in Authenticate
 File "/Applications/", line 545, in MaybeInvokeAuthentication
   datastore_stub._server.Send(datastore_stub._path, payload=None)
 File "/Applications/", line 344, in Send
   f =
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 389, in open
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 502, in http_response
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 427, in error
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 361, in _call_chain
 File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 510, in http_error_default
HTTPError: HTTP Error 404: Not Found
[INFO    ] Authentication Failed

When you see “Authentication Failed” after a 404 error, that’s likely a sign that you have the wrong handler in place to accept the remote_api calls. In app.yaml, make sure that you have a URL handler for /remote_api in your app.yaml and make sure it’s listed above any catch-all handler for It should look like the following:

- url: /remote_api
  script: $PYTHON_LIB/google/appengine/ext/remote_api/
  login: admin
- url: .*

If you’re running the bulk uploader against your development server running on your own machine, then (as per this question and this walkthrough) you should leave out the login: admin line in order to avoid having to authenticate. If you are asked to authenticate, you should use your Gmail username and password. And if you’ve entered the wrong username and password at some point, you may need to delete your cookies file.

Uploading or downloading data often exposes problems with non-ASCII characters in either your CSV file or your AppEngine datastore. If you’re uploading non-ASCII data, make sure to encode data in UTF-8 rather than using the plain str function (as described in this bug thread).

class MyLoader(Loader):
  def __init__(self):
    Loader.__init__(self, 'MyModel', [('field1', lambda x: unicode(x, 'utf-8'))])

And our own Karen Nomorosa and Hyunwoo Park discovered that for downloading non-ASCII data from AppEngine, you should modify this slightly:

lambda x: x.encode('utf-8')

Other problems (or answers) for AppEngine bulk uploading or downloading? Let us know, in the comments or via email.

One Response to “Common AppEngine bulk upload issues”

  1. Thanks,
    I hit the first two problems and this post was really helpful.