Importing Gdata Lib in Google App Engine

577 views
Skip to first unread message

klenwell

unread,
Jan 30, 2010, 3:36:15 PM1/30/10
to GData Python Client Library Contributors
I'm not using setup.py install but rather have the gdata and atom
package inside a third-party directory for my application.

Importing the atom package works fine. For example:
from vendor.google import atom

But when I try:
from vendor.google import gdata

I get an import error:
ImportError('No module named atom')

The problem is line 27 of the gdata package's __init__ file:
import atom

What I don't understand is that even if I explicitly add the package's
directory to sys.path, I still encounter the error. For example, this
is ok:
sys.path.append('<BASEPATH>/vendor')
import google

But the following will raise the error:
sys.path.append('<BASEPATH>/vendor/google')
import atom # or: import gdata

I've exhausted all my avenues. What am I missing? Help appreciated,
Tom

Jeff S

unread,
Feb 4, 2010, 1:53:53 PM2/4/10
to GData Python Client Library Contributors
Hi Tom,

I think sys.path.append should be a viable option, what are you using
for the string? If you placed the gdata and atom directories under
vendor/google in your project, then you should be able to add this to
the path like this:

sys.path.append('vendor/google')

The above would work assuming that your directory structure is like
this

|-- app.yaml
...
|-- vendor
| |-- google
| | |-- gdata
| | | |-- __init__.py
...
| | |-- atom
| | | |-- __init__.py

Hope this helps,

Jeff

klenwell

unread,
Feb 7, 2010, 1:32:36 PM2/7/10
to GData Python Client Library Contributors
Thanks for the response. Strangely, this does not work for me. I
tested this structure:

|-- app.yaml
...
|-- vendor
| |-- google
| | |-- gdata
| | | |-- __init__.py
...
| | |-- atom
| | | |-- __init__.py

...
| | |-- mock_gdata
| | | |-- __init__.py

In my code, I append vendor/google to sys and later include these
lines:

import mock_gdata
import gdata

mock_gdata contains only an __init__.py file and appears to be
successfully imported. But gdata raises an exception. This is the
traceback:

'error': ImportError('No module named gdata',),
'traceback': [('/home/klenwell/projects/appswell/appspot/appswell/
dispatch.py',
70,
'_process',
'self._call_action(self.Controller_)'),
('/home/klenwell/projects/appswell/appspot/appswell/
dispatch.py',
187,
'_call_action',
'return method_()'),
('/home/klenwell/projects/appswell/appspot/appswell/
controllers/demo_controller.py',
306,
'test_import',
'import gdata')]}

If I put gdata and atom in app's root directory (parallel to
app.yaml), they are imported without incident.

Is there a rational explanation for this? Could it have something to
do with the fact that the __init__.py files in gdata and atom aren't
empty?

Tom

mjbruder

unread,
Feb 22, 2010, 9:14:19 AM2/22/10
to GData Python Client Library Contributors
This might help (from http://code.google.com/appengine/articles/gdata.html):

"Using the gdata-python-client library

Google offers a Google Data Python client library that simplifies
token management and requesting data from specific Google Data APIs.
We recently released a version of this library that supports making
requests from Google App Engine applications. In this article we'll
use this library, but of course you're welcome to use whatever works
best for your application. Download the gdata-python-client library.

To use this library with your Google App Engine application, simply
place the library source files in your application's directory, and
import them as you usually would. The source directories you need to
upload with your application code are src/gdata and src/atom. Then, be
sure to call the gdata.alt.appengine.run_on_appengine function on each
instance of a gdata.service.GDataService object. There's nothing more
to it than that!"

mjbruder

unread,
Feb 22, 2010, 9:31:07 AM2/22/10
to GData Python Client Library Contributors
Looks to me like the gdata and atom directories need to go directly
into the root of your app. Then you will be able to use import
statements like 'import gdata.docs.service' or whatever you need from
there.

On Feb 7, 12:32 pm, klenwell <klenw...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages