[Django]-Access to module denied from within GAE dev server

6👍

App Engine runs Python code in a sandbox, and only authorized standard library modules & packages can be imported from your application.

as @mg has mentioned, if you want to allow for 3rd-party modules & packages, you need to bundle them with your application. to do that specifically for feedparser, just drop the feedparser.py file into your top-level App Engine directory (where your app.yaml, index.yaml, and main.py are located).

(UPDATED Oct 2011) also keep in mind the hard limits:

  • max total number of files (app files and static files): 3,000 (upped to 10k in 1.5.5, Oct 2011)
  • max size of an application or static file: 10MB (upped to 32MB in 1.5.5)
  • max total size of all application and static files: 150MB

if you want to save on the total number of files, you can put a wad of .py files in a ZIP so you only pay for one file. although this article is slightly out-of-date — recommending bundling of Django 1.0 which is now included — the technique of bundling modules & packages into ZIP files still apply:

http://code.google.com/appengine/articles/django10_zipimport.html

Official page in the docs which discusses the file limitations:

http://code.google.com/appengine/docs/python/runtime.html#Pure_Python

(UPDATED Nov 2011): The link below features a list of whitelisted Python modules/packages with C code for 2.5. The Python 2.7 runtime frees up many restrictions so much so that the whitelist has become a blacklist. Here are the allowed/whitelisted 2.5 C modules as well as the disallowed/blacklisted 2.7 C modules:

http://code.google.com/appengine/kb/libraries.html

👤wescpy

1👍

Because in GAE you cannot access libraries that are not parts of GAE itself, are not included in GAE, like django 0.96.1, or are not part of your application. Install that library, and every one else, in the same path of your web application.

EDIT

From the documentation:

You can include other pure Python
libraries with your application by
putting the code in your application
directory. If you make a symbolic link
to a module’s directory in your
application directory, appcfg.py will
follow the link and include the module
in your app.

The Python module include path
includes your application’s root
directory (the directory containing
the app.yaml file). Modules you create
in your application’s root directory
are available using a path from the
root. Don’t forget to create
init.py files in sub-directories, so Python will recognize the
sub-directories as packages.

👤mg.

Leave a comment