【问题标题】:Execute python program using php on server在服务器上使用 php 执行 python 程序
【发布时间】:2017-06-15 13:30:13
【问题描述】:

我有一个 python 程序,我想从 php 执行我已经尝试过 "exec,escapeshellcmd,shell_exec,passthru,popen" 但没有人给出结果。

我已经成功执行了“hello word”程序,但是我需要的程序没有执行并且没有显示任何错误。

echo $python = exec("python python/interactive.py");//this file not working
echo $python = passthru("python python/python.py ");// this is working with hello world.
$output = shell_exec($command);
echo $output;

【问题讨论】:

  • 是的,exec 和朋友是解决这个问题的正确方法。你得到什么错误?
  • 我没有收到任何错误。
  • 你能分享你的 php 代码,至少是你调用exec的那一行吗?
  • 我也添加了代码。
  • python/interactive.py 在做什么?听起来它需要一个终端,如果您在网络服务器中运行该 python 程序,它当然不存在

标签: php python exec


【解决方案1】:

如果你想在 web 上执行 python 脚本,我建议你研究像 FlaskDjango 这样的 python web 框架。这是最好的方法。

【讨论】:

  • 实际上是我在不是网络应用程序中使用的python程序,否则我不需要在php中执行python。
猜你喜欢
  • 2015-10-10
  • 1970-01-01
  • 2012-11-10
  • 2014-06-21
  • 1970-01-01
  • 2013-10-29
  • 2017-11-17
  • 1970-01-01
  • 2012-02-16
相关资源
最近更新 更多