I am working on laravel and I must run a python script. I use these codes to run the script.
$process = new Process(['python', __ROOTPATH__.DIRECTORY_SEPARATOR.'pythonscripts'.DIRECTORY_SEPARATOR.'image-classification\train.py', '-p '.json_encode($parameters),'-m '.$parameters['trainingParameters']['model']]);
$process->run();
return $process->getOutput();
But I get an error as below:
Can't determine home directory
To solve this problem, I made some research. More clear one is this but it does not work for me.
#!C:\Users\monst\AppData\Local\Programs\Python\Python39\python.exe
os.environ['HOME'] = "C:/Users/monst/AppData/Local/Programs/Python/Python39"
I run xampp as administrator but it did not work as well.
If I run the script dirrectly, it works
Update 1
I debuged the python script step by step and I realized the error occurs at __import__('models.'+modelName)
line. and modelName = 'lenet/vgg16/vgg19...'
models is a custom package at where the python script is
Update 2
Same codes work by php exec command.