Issue
I am trying to run a Python Script for Image Detection Via a php page and to catch and display the output generated by py script.
Here is my python script href="https://github.com/MicrocontrollersAndMore/OpenCV_3_License_Plate_Recognition_Python/blob/master/Main.py" rel="nofollow noreferrer">GITHUB LINK
I am running the python script using this code :
$command = escapeshellcmd('sudo python Main.py');
$output = shell_exec($command);
echo $output;
This is producing this error :
Traceback (most recent call last):
File "Main.py", line 3, in <module>
import cv2
ImportError: No module named cv2
****But the same script works fine when executed independently with terminal. I have used anaconda for installation of Opencv****
Thanks in advance :)
Solution
Anaconda creates separate environment so you need to start your script using python copy from that enviroment
$command = escapeshellcmd('sudo /home/path_to_anacondad_env/python Main.py');
Answered By - vZ10 Answer Checked By - Katrina (WPSolving Volunteer)