Okay so to execute the python script from inside a Laravel framework you will need to use Symfony subprocess. Entry here is my example. I had to pass some values to python and get them back after python will create a file inside a specific folder. This is a bit challenging cause you must make sure the file was created and so.

Import the following libraries

use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

Working with python

//As for the help I’ve created 2 variables that will help us. The first one is the path to
//python script and another one is the arguments you want to pass to the python.
$scriptLocation = $this->python_path.'pass.py';
$scriptLocation = $this->python_path.'pass.py';

//And for this to work you need to pas an array to the function with specyfic parms
// [0]  -> Should be a name of the program
// [1] -> Should be a path to the script
// [3] - >Should ba an args that you want to pass to the script
$args =  ['python',$scriptLocation, $scriptsArgs]

Running python script and capturing it's output

$process = new Process($args);

// executes after the command finishes
    if (!$process->isSuccessful()) {
        throw new ProcessFailedException($process);
    echo $process->getOutput();