我有一个名为gaend的Google App Engine项目。我正在尝试使用readthedocs为它构建更好的文档。我用过
> sphinx-quickstart
建立我的基础狮身人面像项目。其次是
> sphinx-apidoc -o . ../gaend
生成项目的API列表。然后我跑
sphinx-autobuild . _build/html
+--------- manually triggered build ---------------------------------------------
| Running Sphinx v1.5.2
| loading pickled environment... done
| building [mo]: targets for 0 po files that are out of date
| building [html]: targets for 0 source files that are out of date
| updating environment: 0 added, 1 changed, 0 removed
| reading sources... [100%] gaend
/Users/stephen/gaend/docs/gaend.rst:10: WARNING: autodoc: failed to import module u'gaend.bigquery'; the following exception was raised:
Traceback (most recent call last):
File "/Users/stephen/.virtualenvs/gaend/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 551, in import_object
__import__(self.modname)
File "/Users/stephen/gaend/gaend/bigquery.py", line 1, in <module>
from google.cloud import bigquery
ImportError: No module named google.cloud
...
ImportError: No module named google.appengine.ext
我发现问题在于它无法访问Google Cloud SDK。我在运行单元测试时遇到了类似的问题,而这样做的工作是runner.py。但是,这依赖于在我的系统上的某个位置安装Google Cloud SDK(安装了Python Google App Engine模块)。我如何在构建我的文档的readthedocs服务器上获得Google Cloud SDK(和Python GAE)?
答案 0 :(得分:1)
我是同样的问题,我不记得我在哪里找到了解决方案,也许不解决你的问题,但我解决了我在google_appengine
文件夹和google_appengine/lib/yam/lib
文件夹中添加路径{ {1}}文件位于Sphinx doc文件夹内的源文件夹中,如下所示:
在conf.py
:
conf.py
我知道相对路径会更好,但它对我有用。
狮身人面像需要运行你正在记录的程序是我不理解的东西,但无论如何,这是一个很好的工具。
答案 1 :(得分:0)
我刚刚解决了同样的问题。关于Sphinx + GAE的问题并不多,所以我发布conf.py
代码,让它为我工作,希望能帮助其他人:
import os
import sys
project_id = 'gae-project-id'
# environment variables that several utils are assuming are present
if not os.environ.get('SERVER_SOFTWARE', None):
os.environ['SERVER_SOFTWARE'] = 'Development-'+project_id
if not os.environ.get('APPLICATION_ID', None):
os.environ['APPLICATION_ID'] = 'dev~'+project_id
# project root
sys.path.insert(0, os.path.dirname(__file__))
# downloaded third party libs
sys.path.insert(0, os.path.dirname(__file__)+"/lib")
# path to gae sdk
sdk_path = os.path.join('~/google-cloud-sdk', 'platform/google_appengine')
try:
import google
google.__path__.append("{0}/google".format(sdk_path))
except ImportError:
pass
sys.path.insert(0, os.path.expanduser(sdk_path))
import dev_appserver
dev_appserver.fix_sys_path()