Scenario:
I have a php page in which I call a python script. 
Python script when run on the command line (Linux) shows output on the command line, as well as writes the output to a file.
Python script when run through php, doesn't do either.
Elaboration:
I use a simple system command in PHP to run the python script as:
/var/www/html/1.php:
    system('/usr/python/bin/python3 ../cgi-bin/tabular.py 1');
/var/www/cgi-bin/tabular.py
--This python file basically parses a data file, uses python's regular expression to search for specific headings and outputs the headings to the stdout, as well as write it to a file.
This python script has a few routines in it which get executed, so I put print statements to debug. I noticed only a few initial print statements' output in the PHP page, all the ones from the function that actually does something are not seen.
Also, as part of my test, I thought well the py script is in a different folder so let me change it to the /var/www/html folder, no go.
I hope I captured the problem statement with sufficient detail and someone is able to reproduce this issue at their end. If I make any progress on this one myself, I'll annotate this question. Thanks everyone.
Gaurav
Check that the user the python script is running is has write permissions in CWD. Also, try shell_exec() or passthru() to call the script, rather than system().
When calling a Python script from a PHP script, temporary file that is created on a console run, is not created via the PHP invocation