I have a PHP code that calls a Python code in the back end. As long as there are no libraries involved (I use matplotlib in this case), the output of the python is displayed in the web-browser. However, when I import matplotlib, the browser just goes blank. I know this is a permission issue, but cannot recall how to set up the permissions of the libraries correctly.
I am running on AWS ubuntu, with PHP and Python3
Here is the PHP code
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$output = shell_exec('/home/ubuntu/plotExample.py');
echo $output;
?>
Here is the python example:
#!/usr/bin/python3
import sys
from matplotlib.pyplot import figure
print ("Hello World")
What works (prints "Hello World"
):
php /var/www/html/phptest.php
Same php code on browser gives a blank page.
Now, if I comment out "from matplotlib.pyplot import figure
", the Hello World
shows up in the browser