title: calling python from php and save files,
body: <p>I have trying to call a python code from bar.php like</p>
  
  <pre><code>$cmd = "python foo.py";
  system($cmd);
  </code></pre>
  
  <p>It runs with no problem. However, foo.py should save a file on disk. And it wasn't there. I somehow figured out that the user running the web server is www-data.</p>
  
  <p>I tried running the php script from command line with user www-data
      $ php bar.php
  It runs OK and saved the file, so user www-data should have permission to write to the directory.</p>
  
  <p>I noticed that there is a vote on "would not be helpful to other user". However, when you have a php service and you have code written in other language like python, knowing this is necessary. </p>
  
  <p>Thanks for all suggestions.</p>
  
  <p>I suspect it is b/c I use Matplotlib in the python code
  in foo.py, I have code like</p>
  
  <pre><code>pl.scatter(data,...)
  pl.plot(data,...)
  pl.legend()
  pl.save('path/to/bam.png')
  </code></pre>
  
  <p>Maybe when calling from the web, it can draw images. Is that possbile? If so, is there any way to fix it? Thanks!</p>