سؤال

Sphinx throws this error when I try to make docs for a module in which I import from google.appengine.ext import ndb:

Traceback (most recent call last):e/adapters                                    
  File "/usr/local/lib/python2.7/dist-packages/Sphinx-1.1.3-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
  File "/home/peto/workspace/mymodule.py", line 11, in <module>
    from google.appengine.ext import ndb
  File "/usr/lib/pymodules/python2.7/google/appengine/ext/ndb/__init__.py", line 7, in <module>
    from tasklets import *
  File "/usr/lib/pymodules/python2.7/google/appengine/ext/ndb/tasklets.py", line 68, in <module>
    from .google_imports import apiproxy_stub_map
  File "/usr/lib/pymodules/python2.7/google/appengine/ext/ndb/google_imports.py", line 33, in <module>
    from google.appengine.ext import gql
ImportError: cannot import name gql

I fixed the same problem with yaml before by including it in sys.path but it doesn't work for gql. I have my conf.py configured like this:

gae_path = '/usr/lib/google-app-engine'

sys.path[0:0] = [
    gae_path,
    os.path.join(gae_path, 'lib'),
    os.path.join(gae_path, 'lib', 'yaml'),
    os.path.join(gae_path, 'lib', 'yaml', 'lib'),
    os.path.join(gae_path, 'google'),
    os.path.join(gae_path, 'google', 'appengine'),
    os.path.join(gae_path, 'google', 'appengine', 'ext'),
    os.path.join(gae_path, 'google', 'appengine', 'ext', 'gql'), # The gql package is really there
    os.path.abspath('../../'),
]
هل كانت مفيدة؟

المحلول

The problem was that I had in my sys.path another google package at /usr/lib/pymodules/python2.7/google/appengine where there was no ext.gql package. I removed that folder and it worked like a charm.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top