views:

132

answers:

2

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?

+1  A: 

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
+3  A: 

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).

also keep in mind the hard limits:

  • max total number of files (app files and static files): 3,000
  • max size of an application file: 10 megabytes
  • max size of a static file: 10 megabytes
  • max total size of all application and static files: 150 megabytes

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

wescpy