Do you need any permission for PHP to call python script under windows?

Why when PHP calls the Python script, it is possible for the script to execute some simple output
for example:

p.py
print(123);

:

from os import startfile  -sharp
path = "D:\Wildlife.wmv"
startfile(path)

:
p=os.popen("rv D:\a.AVI"); //RV


CMDPythonPHP

php:
shell_exec("python D:\pytest\play.py")

:exec("python D:\pytest\play.py",$out,$status)
$status 0 
May.08,2022

try using the full python interpreter path instead of python


should be the execution directory (the reason for the working directory). When PHP is called, it becomes the directory of the current PHP. So change the working directory, or set the path of the file opened by py to an absolute path.

< H1 > change the work path < / H1 >

import os
os.chdir

< H1 > View the path to the py execution file < / H1 >

import sys
print (sys.argv [0])

< H1 > View current work path < / H1 >

import os
print (os.getcwd ())

Menu