从PHP运行Python脚本 [英] Run Python script from PHP

查看:66
本文介绍了从PHP运行Python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从PHP运行Python脚本.该脚本的语法很好,当我从命令行运行它时,它会在它旁边生成一个图像文件.当我从命令行运行PHP文件(包含Python exec)时,它会生成一个图像文件.很好.问题是:当我使用浏览器并运行PHP时,它不会生成任何图像文件.我使用的是Xubuntu OS.

I want to run Python script from PHP. The script's syntax is good, when I run it from command line it generates an image file next to it. When I run the PHP file (contains Python exec) from command line it generates an image file. It's good. The problem is: when I use browser and run PHP it isn't generate any image file. I use Xubuntu OS.

推荐答案

问题是matplotlib后端设置.我更改为"Agg",并且plot函数正常工作.

The problem was the matplotlib backend setting. I changed to 'Agg' and the plot function worked fine.

这篇关于从PHP运行Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆