简体   繁体   English

Apache 不允许 PIL 工作

[英]Apache doesn't let PIL work

I wrote "Apache doesn't let PIL work" as title but I'm not sure about if this is the case or not.我写了“Apache 不允许 PIL 工作”作为标题,但我不确定是否是这种情况。 I have a php script that sends json data to a py file that will process an image according to this json data.我有一个 php 脚本,它将 json 数据发送到一个 py 文件,该文件将根据此 json 数据处理图像。 The communication between languages works.语言之间的交流有效。 But when I add the line for importing PIL to py file, php returns NULL on browser.但是当我添加将 PIL 导入 py 文件的行时,php 在浏览器上返回 NULL。 It's also working when I run the php script with command line but I have to run it on web browser.当我使用命令行运行 php 脚本时它也可以工作,但我必须在 Web 浏览器上运行它。

This is the php script:这是php脚本:

<?php

$result = exec('python somecode.py ' . escapeshellarg(json_encode('897')));
$resultData = json_decode($result, true);

var_dump($resultData);
?>

this is the py file:这是py文件:

import sys, json

data = json.loads(sys.argv[1])
print data

this works just fine and gives me the output of int(897) which is expected.这工作得很好,并为我提供了预期的int(897)输出。 When I add the line of from PIL import Image , it gives NULL on browser but it still can being ran on command line without any problem.当我添加from PIL import Image的行时,它在浏览器上给出NULL但它仍然可以在命令行上运行而没有任何问题。 I didn't even add the code for processing image, just trying to import PIL.我什至没有添加处理图像的代码,只是尝试导入PIL。

EDIT: I tried to import numpy, it didn't prevent the code from running.编辑:我尝试导入 numpy,它并没有阻止代码运行。 It runs on browser even I import numpy.即使我导入 numpy,它也能在浏览器上运行。 So, probably problem is related with PIL.所以,问题可能与 PIL 有关。

It was about the image's path.这是关于图像的路径。 I changed it to a proper one, and the problem is fixed.我把它改成合适的,问题就解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM