我有一个运行烧瓶应用程序(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) e 得到特定错误:
! Package inputenc Error: Unicode char ‐ (U+2010)
(inputenc) not set up for use with LaTeX.
在这里检查一种解决方案,我在文件中手动添加以下行:
\DeclareUnicodeCharacter{2010}{-}% support older LaTeX version
并且工作了!
但是我如何使用 PYLATEX 做到这一点?有其他方法来处理这种情况吗?因为在我看来,设置所有不能用乳胶处理的 UnicodeCharacter 太难了。