By running python script with php - working in console but not in web browser
one text
Solution:
There can be (at least) two problems.
First you need to check/know, that the server maid use another environment. I believe, that you did not use the webserver-user for your local checks. So I would try to use absolute pathes. You also have to make sure, that the python-environment (whatever you have configured) has to be the same as your local user.
Second you need to make sure, that you have all rights to run the file (the webserver, that is used by the webserver needs to have at least reading right on report_gen.py).
Source