我目前安装了 python 2.7 作为 OSX 的一部分,最近安装了 3.5.2。
我在我的 mac 上使用 XAMPP 运行本地网络服务器,当我从 apache 中执行 python 脚本时,它加载正常:
$executePython = "python " . __DIR__ . "/cycle/cutoff.py $device_id $processPreviousMinutes";
exec("$executePython");
但是,当我将 python 替换为 python3 时,我的脚本拒绝运行。我可以使用这两个版本从命令行手动调用它,但是 apache 帐户/守护进程似乎无法访问 python3。这是否与我忽略的配置文件有关?
请您参考如下方法:
我们不想在最新的 OSX 上弄乱系统范围的路径。如果您像这样在脚本中添加 python3 路径,然后执行正常操作,会怎样
putenv("PATH=/usr/local/bin/:" . exec('echo $PATH'));
$executePython = "python3 " . __DIR__ . "/cycle/cutoff.py $device_id $processPreviousMinutes";
exec("$executePython");
putenv 只是将您的 python3 路径添加到 XAMPP 的 apache 中的任何当前路径。
