'I can use it when I type python commands in EC2, but when I do python commands in Laravel's process exec, I can't use it

What I want to do

I want to use python3 commands in the code I created within the Laravel project in EC2.

Environment

AWS EC2 AmazonLinux

Laravel6

Problem

In the Laravel project.

$path = '../file.py';
$process = new Process(['python3', $path]);
$process->mustRun();

messsage

The command "'python3' '../directory/file.py' '6'" failed.
Exit Code: 127(Command not found)
Working directory: /var/www/html/my-laravel-project/public
Output:
================
Error Output:
================
sh: line 0: exec: python3: not found

What I did

python3 is installed

in EC2

python3 --version
Python 3.9.0

of course It works fine locally.

Dear all, what should I try?

Thank you in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source