How to debug the error 'sh: 1: python3: not found' in running Python script in PHP

烂漫一生 提交于 2021-01-29 09:32:48

问题


I want to run my Python script using PHP's shell_exec() and xammp on Mac. When I run it on terminal it is working, but when I run it on browser it shows this error 'sh: 1: python3: not found'

PHP

$command = escapeshellcmd("python3 scrape.py");
$command_output = shell_exec($command." 2>&1");

echo $command_output;

Python

#!/usr/bin/env python3
import cgi,cgitb
import urllib.request

from bs4 import BeautifulSoup
from bs4.element import Comment
from datetime import datetime
import re
import json

print ("Content-Type: text/plain;charset=utf-8\n")

print("hello")

来源:https://stackoverflow.com/questions/55646460/how-to-debug-the-error-sh-1-python3-not-found-in-running-python-script-in-p

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!