使用使用php文件导入的外部库执行python脚本

时间:2018-12-13 17:42:47

标签: php python

我无法使用使用php文件导入的外部库执行python脚本。执行一个带有系统库(例如sys)的简单文件,浏览器中将显示输出,但使用外部库时浏览器未显示任何输出。 1.我的php文件-

<?php
putenv('PYTHONPATH=/home/saurabh/anaconda3/bin/python3.6');
$output = `python3 script.py`;
echo $output;
?> 

2。 python文件

#!/usr/bin/env python
from PIL import Image
import pytesseract
import sys
image = Image.open("testImage2.jpeg")
text = pytesseract.image_to_string(image, lang="eng")
print(text)

0 个答案:

没有答案