Access to module denied from within GAE dev server
Question: I am developing an app for GAE.

Having installed the "feedparser" module with setuptools, I tried importing it
(with "import feedparser") statement. However, the module does not load and
when I look at the dev_appserver.py debug log on screen, I see the following:

    
    
    Access to module file denied: /usr/local/lib/python2.6/dist-packages/feedparser-4.1-py2.6.egg/feedparser.py
    

So GAE dev server cannot access the module but I can't figure out why. The
path is correct and the file is accessible.

I am fairly new to Python/Django/GAE - what am I missing?


Answer: 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>

