tony9099
tony9099

Reputation: 4717

Error while trying to run PHP script from Python

I have WAMP installed on my Windows PC. I have a python script that has the following code, which is supposed to run my php script located in www of wamp (C:\wamp64\www)

import subprocess
subprocess.call("php C:\wamp64\www\index.php")

I also tried the below but it did not work also

import subprocess
subprocess.call("C:\wamp64\bin\php\php5.6.31\php.exe C:\wamp64\www\index.php")

However, when I run the python code from IPython I get the following error. (see image)

Error in IPython

Upvotes: 0

Views: 146

Answers (1)

mwweb
mwweb

Reputation: 7915

Add full path of PHP

subprocess.call("C:/wamp64/bin/php/php5.6.31 C:/wamp64/www/index.php")

Or Add php to environment variables. Open CMD and type:

SET PATH=%PATH%;C:\wamp64\bin\php\php5.6.31

Upvotes: 1

Related Questions