Matplotlib in Php
You can call Python code from within a Php script and get the return value and output like this:
exec('python mycode.py', $output, $return); foreach ($output as $line) print "$line<br/>";
To test if everything is ok for your web server to call the python script, try:
sudo -u www-data python mycode.py
From this I found out that the Python call
import matplotlib was failing with the error:
RuntimeError: ‘/home/azimout’ is not a writable dir; you must set /home/azimout/.matplotlib to be a writable dir.
This can be resolved by adding the following line to your Python code before you import matplotlib:
os.environ[ 'HOME' ] = '/tmp/'