I'm running Laravel project on Nginx server, in which I call a python file using below command by passing arguments
$result = exec("python3 path/to/file.py $data");
In the python file, there is a line of code
font_file = base_path+'/fonts/LiberationMono-Bold.ttf'
cmd = ["ttf2cxf_stream",
"",
"-s","5.0",
font_file,"STDOUT"]
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
This is giving an error that it can't open the font file which is present on that location. The owner of the project is ubuntu:www-data and the font file is present in that project. I also tried giving it 777 permission but still no luck.
Now when I run the same command in terminal
python3 path/to/file.py "data"
It successfully runs without the font file access error. What could be the issue?
I had faced similar issue while using "ttf2cxf_stream" library to open font - ttf files. Please check if ttf2cxf_stream exist in /usr/bin directory if not then try copying it from /usr/local/bin/ directory and see if you can run py file through PHP code.