dimanche 4 août 2019

Run python script from Laravel 5.8

I am using Laravel 5.8 and need to run python script from it

I installed python3.6 and added it to the windows path it is working fine from command line

C:\Users\mmm>python -V
Python 3.6.6

C:\Users\mmm>

from laravel controller I added below code

$process = new Process("python.exe 'path/to/scipt.py'");
        $process->run();

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

dd(json_decode($process->getOutput(), true));

when call this api from postman it return the below error

Error Output:
================
'python.exe' is not recognized as an internal or external command,
operable program or batch file.
"""

any suggestions how to solve this problem ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire