python - 当模板存在时,为什么 rst2pdf 会给出 TemplateNotFound 错误?

标签 python python-sphinx rst2pdf

我正在利用 rst2pdf 库通过 Sphinx 生成 PDF 文档。但是,当我尝试执行此操作时,最终出现以下错误:

[exec] sphinx-build -b pdf -d stage/doctrees   source/welcome stage/pdf
     [exec] Running Sphinx v1.8.5
     [exec] ['support/style']
     [exec] loading pickled environment... done
     [exec] building [mo]: targets for 0 po files that are out of date
     [exec] building [pdf]: targets for 4 source files that are out of date
     [exec] updating environment: 0 added, 0 changed, 0 removed
     [exec] looking for now-outdated files... none found
     [exec] processing WelcomeToRealtimeDespatch... 
     [exec] index 
     [exec] 01-introduction 
     [exec] 03-market 
     [exec] 05-administration 
     [exec] resolving references...
     [exec] done
     [exec] writing WelcomeToRealtimeDespatch... 
     [exec] FAILED
     [exec] build succeeded.
     [exec] 
     [exec] Build finished. The PDF files are in stage/pdf.
     [exec] /usr/local/lib/python2.7/dist-packages/rst2pdf/pdfbuilder.py:207: RemovedInSphinx20Warning: env.create_index() is deprecated. Use sphinx.environment.adapters.indexentreis.IndexEntries instead.
     [exec]   genindex = self.env.create_index(self)
     [exec] [ERROR] pdfbuilder.py:133 /home/catherine/workspace/rtd2/documentation/source/welcome/../../support/style/apicover.tmpl
     [exec] Traceback (most recent call last):
     [exec]   File "/usr/local/lib/python2.7/dist-packages/rst2pdf/pdfbuilder.py", line 130, in write
     [exec]     docwriter.write(doctree, destination)
     [exec]   File "/usr/local/lib/python2.7/dist-packages/docutils/writers/__init__.py", line 80, in write
     [exec]     self.translate()
     [exec]   File "/usr/local/lib/python2.7/dist-packages/rst2pdf/pdfbuilder.py", line 600, in translate
     [exec]     date=date
     [exec]   File "/usr/local/lib/python2.7/dist-packages/rst2pdf/createpdf.py", line 112, in renderTemplate
     [exec]     template =jinja_env.get_template(tname)
     [exec]   File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 830, in get_template
     [exec]     return self._load_template(name, self.make_globals(globals))
     [exec]   File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 804, in _load_template
     [exec]     template = self.loader.load(self, name, globals)
     [exec]   File "/usr/local/lib/python2.7/dist-packages/jinja2/loaders.py", line 113, in load
     [exec]     source, filename, uptodate = self.get_source(environment, name)
     [exec]   File "/usr/local/lib/python2.7/dist-packages/jinja2/loaders.py", line 168, in get_source
     [exec]     pieces = split_template_path(template)
     [exec]   File "/usr/local/lib/python2.7/dist-packages/jinja2/loaders.py", line 31, in split_template_path
     [exec]     raise TemplateNotFound(template)
     [exec] TemplateNotFound: /home/catherine/workspace/rtd2/documentation/source/welcome/../../support/style/apicover.tmpl

我可以确认模板位于路径:

ls -l /home/catherine/workspace/rtd2/documentation/source/welcome/../../support/style/apicover.tmpl
-rwxrwxrwx 1 catherine catherine 436 Feb 14  2018 /home/catherine/workspace/rtd2/documentation/source/welcome/../../support/style/apicover.tmpl

有什么想法为什么 pdfbuilder 可能无法找到提供的模板吗?

最佳答案

看起来 rst2pdf 现在禁止在模板路径中使用“..”,尝试之前规范化路径,或者使用旧版本的 rst2pdf 并向开发人员询问其背后的细节。

关于python - 当模板存在时,为什么 rst2pdf 会给出 TemplateNotFound 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55949641/

相关文章:

python - 符号条件和

python-sphinx - 将 Sphinx 与 rst2pdf 结合使用时如何添加节编号

restructuredtext - 如何禁用 rst2pdf 文档首页上的页眉?

css - rst2pdf 页眉/页脚文本颜色

Python - 基于多个排序项的元组排序列表

python - django modelForm 不验证添加的外键

python-sphinx - 在 Sphinx 中使用 noindex 和词汇表

python - Django 上的 Sphinx-apidoc 在 `django.core.exceptions.AppRegistryNotReady` 上构建 html 失败

latex - 使用 Sphinx 文档如何为 HTML 构建指定 png 图像格式,为 Latex/PDF 构建指定 pdf 图像格式?

python - 尝试让终端在 Emacs 中工作