How to call Python Script from class in Symfony

I’m wondering how I can call a python script from a class in Symfony. I keep getting an error that it can’t locate the script.

May 28 13:54:13 |INFO | PHP    python: can't open file '': [Errno 2] No such file or directory

The code is as followed:

        $python = shell_exec("python");
        echo $python;     

The script is outside the symfony project, but I’m not quite sure how to get the path relative to the class file.

Source: Symfony Questions

Was this helpful?

1 / 0

Leave a Reply 1

Your email address will not be published. Required fields are marked *



Try like that: For exemple, you have your php file in C:users/yourPc/yourAppli/App/youFile.php
And your python file in C:users/yourPc/scripts/
Your relative path will be : ../../scripts/