我有一个网站运行一个烧瓶应用程序(python 3),当我试图生成一个pdf时,我得到了以下错误:
Traceback (most recent call last):
File "./web/frontend/printr.py", line 204, in generate_files
File "/env/flask3/lib/python3.5/site-packages/pylatex/document.py", line 228, in generate_pdf
stderr=subprocess.STDOUT)
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 708, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['latexmk', '--pdf', '--interaction=nonstopmode', 'a05f271c-1a7b-4996-9533-1c8ff17a90bf.tex']' returned non-zero exit status 12
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/env/flask3/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/env/flask3/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/env/flask3/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/env/flask3/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/env/flask3/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/env/flask3/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/env/flask3/lib/python3.5/site-packages/flask_login/utils.py", line 228, in decorated_view
return func(*args, **kwargs)
File "./web/frontend/views.py", line 690, in report
File "./web/frontend/printr.py", line 206, in generate_files
File "/env/flask3/lib/python3.5/site-packages/pylatex/document.py", line 228, in generate_pdf
stderr=subprocess.STDOUT)
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 708, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['xetex', '--interaction=nonstopmode', 'a05f271c-1a7b-4996-9533-1c8ff17a90bf.tex']' returned non-zero exit status 1守则:
try:
doc.generate_pdf(file,clean_tex=True)
except Exception as e:
doc.generate_pdf(file,clean=False,compiler='xetex')选项clean=False转储许多文件包括*.tex,因此使用服务器上的命令行我再次尝试(pdflatex file_name.text)获得了特定的错误:
! Package inputenc Error: Unicode char ‐ (U+2010)
(inputenc) not set up for use with LaTeX.检查一个解决方案here --我手动在文件中添加了以下行:
\DeclareUnicodeCharacter{2010}{-}% support older LaTeX version 而且起作用了!
,但是我如何使用PYLATEX?来处理这种情况呢?因为在我看来,设置所有无法用乳胶处理的UnicodeCharacter太难了。
发布于 2017-09-02 04:16:51
我修正了修改编译器。XeTeX和LuaTeX将允许您输入unicode,而无需抱怨。
if output == 'pdf':
try:
doc.generate_pdf(file,clean_tex=True)
except Exception as e:
doc.generate_pdf(file,clean=False,compiler='lualatex')
else:
doc.generate_tex(file)https://stackoverflow.com/questions/45780722
复制相似问题