0

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

7
  • try subprocess.call("php C:/wamp64/www/index.php") - \ is an escape character Commented Sep 10, 2017 at 14:53
  • Try passing raw string to the function subprocess.call(r"php C:\wamp64\www\index.php") and if possible, state the full path to the php binary Commented Sep 10, 2017 at 14:54
  • @rndus2r both suggestions did not work Commented Sep 10, 2017 at 14:56
  • 1
    subprocess.call("C:/wamp64/bin/php/yourphpversion C:/wamp64/www/index.php") Commented Sep 10, 2017 at 14:58
  • 1
    subprocess.call("C:/wamp64/bin/php/php5.6.31 C:/wamp64/www/index.php") try this Commented Sep 10, 2017 at 15:05

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.