我正在使用PHP和XAMPP
。我已经启用了端口localhost:8080
,我想从我的PHP脚本(index.php
)执行一个python脚本(Main.py
)。我的PHP脚本位于:
/Users/User/.bitnami/stackman/machines/xampp/volumes/root/htdocs/index.php
Python脚本位于:
/Users/User/.bitnami/stackman/machines/xampp/volumes/root/htdocs/Main.py
。在
我的Python脚本如下:
print('Hello World')
我的PHP脚本如下:
^{pr2}$(/usr/local/bin/python3
是which python3
在终端的输出)
但是,我在localhost:8080
得到的输出是:
string(40) "sh: 1: /usr/local/bin/python3: not found"
我还用exec()
测试了我的行的不同变体,例如写了exec('/Users/User/.bitnami/stackman/machines/xampp/volumes/root/htdocs/Main.py ' . ' 2>&1')
,但是没有返回正确的输出。在
我做错了什么?我该怎么解决?
我知道在StackOverflow(Running a Python script from PHP,Can't execute Python script from PHP document,Python Script Failing to Execute from PHP exec(),How to properly call Python 3 script from PHP?)上也有类似的帖子,但这些文章对我来说都不起作用。在
我想知道我的问题是否与我没有进行任何配置来在XAMPP
上运行Python脚本有关,正如这里的一些文章(Running Python scripts with Xampp)中所描述的那样。在
目前没有回答
相关问题 更多 >
编程相关推荐