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
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
|-- 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
"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!"
On Feb 7, 12:32 pm, klenwell <klenw...@gmail.com> wrote: