简体   繁体   English

在 Ubuntu 网络服务器上使用 PHP 使用 pdflatex 执行 python 脚本?

[英]Executing python script with pdflatex using PHP on Ubuntu webserver?

I am trying to execute a python script which uses pdflatex using php. Running the python script via command line works well.我正在尝试执行一个 python 脚本,该脚本使用 php 使用 pdflatex。通过命令行运行 python 脚本效果很好。

But if I try to call it with php, it throws this error:但是如果我尝试用 php 调用它,它会抛出这个错误:

I can't write on file mylatex.log'.我无法写入文件 mylatex.log'。 (Press Enter to retry, or Control-D to exit; default file extension is `.log') Please type another transcript file name: , Emergency stop ! (按 Enter 重试,或 Control-D 退出;默认文件扩展名是“.log”)请输入另一个成绩单文件名:,紧急停止! ==> Fatal error occurred, no output PDF file produced! ==> 发生致命错误,没有生成 output PDF 文件!

So there seems to be a permission error.所以似乎存在权限错误。

This is the way I am trying to call the php file:这是我尝试调用 php 文件的方式:

$command = escapeshellcmd('python3 /home/ubuntu/test.py');
$output = shell_exec($command);
echo $output;

The mylatex.log file has 777 permission as a test. mylatex.log 文件具有 777 权限作为测试。

Is there a way to execute a python script which uses a library like pdflatex?有没有办法执行 python 脚本,它使用像 pdflatex 这样的库?

I solved the error by adding the php file to the same directory as the python file.我通过将 php 文件添加到与 python 文件相同的目录来解决该错误。 Then it works.然后就可以了。 There seems to be a problem to call pdflatex in a different directory.在不同的目录中调用 pdflatex 似乎有问题。 Thanks for the help.谢谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM