Everyone know if it’s possible to run python under php?

Here is what I mean…

I’ve got some vars in php and I post them to a .py page in my cgi-bin/ folder,

Is it possible to include the python page into the php one, or some thing similar, in order to run only one page and not load an other one?! That’s because I could need to run the page with a cron

Thanks everybody for your help and/or ideas!



I’m not up-to-date with using Python within PHP. Try this site:


I guess it’s possible if you keep in mind the different mechanics between the files. I’m afraid you’re gonna have to use exec() in PHP to fire up the Python script though, as PHP has no native functions to call and execute Python code that I know of.

Perhaps there’s a library available for this sort of thing?

Thanks boobay! I will take a look! It could be helpfull!

And thanks Zyppora I tried with exec(), but it’s not working at the moment! I will try again!

Thanks! Bye!

If you use the EXEC or SHELL_EXEC please keep in mind that it runs as the user that the Webserver uses (Apache?) So if that User does not have permissions to execute the script, then it will fail.

I have used shell_exec and exec with good success to do similar things (not python but others). I too had to adjust permissions. Remember that when you are developing these, to always keep a check on your error logs.

Good luck

Sponsor our Newsletter | Privacy Policy | Terms of Service