I have gdata library install on my ArchLinux, and a simple application which imports atom library at the beginning, when I run gapp engine and access that web app,
$ python2.5 ./dev_appserver.py ~/myapp
It throws exception ‘No module named atom’. But when I run ‘import atom’ in Python2.5 interactive mode, it works well. How can I import atom module in my GAppEngine applications?
Add atom.py to the same directory you keep you GAE Python sources in, and make sure it’s uploaded to the server when you upload your app. (The upload happens when you do
appcfg.py update myapp/unless you go out of your way to stop it; use the--verboseflag on the command to see exactly what’s being uploaded or updated).(Or, if it’s a large file, make a zipfile with it and in your handler append that zipfile to sys.path; see zipimport for example).
This assumes that you have a single file
atom.pywhich is what you’re importing; if that file in turns imports others you’ll have to make those others available too in similar ways, and so on (see modulefinder in Python’s standard library for ways to find all modules you need).If
atomis not a module but a package, then what you get onimportis the__init__.pyfile in the directory that’s the package; so the same advice applies (and zipimport becomes much more attractive since you can easily package up any directory structure e.g. with azip -rcommand from the Linux command line).If at any point (as modulefinder will help you discover) there is a dependency on a third party C-coded extension (a
.soor.pydfile that Python can use but is not written in pure Python) that is not in the short list supplied with GAE (see here), then that Python code is not usable on GAE, as GAE supports only pure-Python. If this is the case then you must look for alternatives that are supported on GAE, i.e. pure-Python ways to obtain the same functionality you require.