我正在使用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并向开发人员查询其背后的含义。