【发布时间】:2019-02-09 22:38:25
【问题描述】:
我正在使用 Python 中的 Bottle 开发微服务,我需要使用 .tex 文件生成 PDF。我正在使用 subprocess 生成 PDF,但我一遍又一遍地收到相同的错误:
Traceback (most recent call last):
File "/Users/casa/Desktop/tesisform/bottle.py", line 763, in _handle
return route.call(**args)
File "/Users/casa/Desktop/tesisform/bottle.py", line 1577, in wrapper
rv = callback(*a, **ka)
File "tesis.py", line 114, in tesis_form
subprocess.check_call(["./runtex", texfname])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['./runtex', u'111111']' returned non-zero exit status 127
我已经尝试了在 Stackverflow 中针对相同错误找到的所有解决方案,但似乎都没有解决我的问题。我的代码如下
@route('/pdf')
def tesis_form():
actn = request.query.actn
fname = "actas/"+actn + ".json"
with open(fname,"r") as f:
data = json.load(f)
tex = template('tesis-evaluation-tex', data)
tex = tex.encode('utf-8')
texfname = "%s" % (actn)
with open("tmp/"+actn+".tex","w") as f:
f.write(tex)
subprocess.check_call(["./runtex", texfname])
return static_file(actn+".pdf", root='tmp')
这是我的 runtex 文件
echo $1
cd tmp
pdflatex $1
任何帮助将不胜感激
【问题讨论】:
-
通过命令行运行
runtex脚本是否有效?如果是,你能告诉我们完整的命令吗? -
是的,没有意识到我正在使用的计算机没有安装 LaTeX 发行版,因此 pdflatex 命令不起作用。我的错,谢谢你现在这将解决我的问题!
标签: python python-2.7 bottle