我有一个运行CentOS 7的Linux机器,安装了Python2.7.5。我正在尝试运行Arduino-CLI,这是一个需要Python的可执行文件。我写了一个命令来编写草图。从右边看,它可以有效地编译。
当我使用sudo_exec()在PHP中运行相同的命令时,它给出了如下内容:
Error during build: exec: "python": executable file not found in $PATH对于上下文,我是作为终端和PHP的网络用户登录的。我能做些什么来解决这个问题?

发布于 2021-01-23 07:03:04
最后我解决了这个问题。在shell_exec()中,PHP不定义PATH环境变量。它也不知道当前的工作目录。因此,在shell_exec()之前添加这几行代码就可以了:
chdir("/home/gyropalm/subdomains/app/studio"); //set current working directory
putenv("PATH=/usr/bin/"); //required to define python path or Arduino-CLI complainshttps://stackoverflow.com/questions/65855888
复制相似问题