I currently have python 2.7 installed as part of OSX, and recently installed 3.5.2.
I'm running a local webserver on my mac using XAMPP, and when I execute the python script from within apache, it loads fine:
$executePython = "python " . __DIR__ . "/cycle/cutoff.py $device_id $processPreviousMinutes";
exec("$executePython");
However, when I replace python with python3 my script refuses to run. I can invoke it manually from the command line using both versions, however it seems like the apache account/daemon doesn't have access to python3. Would this be something to do with a configuration file that I've overlooked?
1 Answer 1
We don't want to mess up with the system wide path on the latest OSX. What if you add the python3 path in your script like this and then do your normal stuff
putenv("PATH=/usr/local/bin/:" . exec('echo $PATH'));
$executePython = "python3 " . __DIR__ . "/cycle/cutoff.py $device_id $processPreviousMinutes";
exec("$executePython");
putenv just adds your python3 path to the whatever current path is in your XAMPP's apache.
$executePythoncommand with>>/tmp/errorlog.log 2>&1and receivedsh: python3: command not foundwhen apache is running as daemon user. When I hardcode the path to/usr/local/bin/python3it runs! However, I'd like to specify justpython3, so how does one do this?echo $PATHI get:/usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/git/binso my own account can just run python3 from anywhere, but the apache daemon account can't (but it can run python).