I've read this question (and many more web pages) in order to figure out how to run a simple python script via a Wordpress plugin.

However, I couldn't do it: I always get a "Blank" output.

No errors were displayed.

How can I execute a python function via Wordpress plugin?


You should not be able to run any script on your server from your PHP. This is a security nightmare you should avoid. If you just have to be able to communicate with some random script on your server you should restrict the ability to only trusted computers (best thing use a different site which uses a different php.ini for that) or find a roundabout way to do that like using write to a file monitored by the python script to pass parameters. (open socket in your python can also be an option).

If as you say in the comments you need to process the output on your local machine, just use a wget or whatever is its python equivalent to get the output from the site and then process it.

  • Actually, I really need python to process the PHP output. Since I'm working at my Localhost, security shouldn't be a problem here. – N. H. Deutschland Aug 15 '18 at 5:25
  • edited to take this into account – Mark Kaplun Aug 15 '18 at 5:37
  • Thanks for your suggestion! Back to the answer, are there any online references for me to apply that "roundabout way"? – N. H. Deutschland Aug 15 '18 at 6:05
  • far from being a python expert but this seems to be the way to go stackoverflow.com/questions/24346872/… – Mark Kaplun Aug 15 '18 at 6:13
  • Hmm, I'll just go with open socket then. Cheers! – N. H. Deutschland Aug 15 '18 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.