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
A permission problem is most likely the case.
If apache is running as apache, then it will not have access to write to a file unless

The file is owned by apache
The file is in the group apache and group writable
The file is world writable

This is a "sticky" problem on a multi-user machine, as different people have access to Apache.  
Try chmod 666 output.txt on the file and then re-run your test.

Considerations:

Have the python script write the output to a database
Use PHP's popen functionality to open the process and communicate over pipes
Re-write using PHP's regular expressions
Write the output file to /tmp and then read the results using PHP as soon as the python script is done.
etc...
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