为什么它不能正确执行python脚本?拉韦尔西蒙尼
运行python脚本后出错:为什么它不能正确执行python脚本?拉韦尔西蒙尼,python,laravel,symfony,Python,Laravel,Symfony,运行python脚本后出错: The command "D:\Python\python.exe "/scripts/HelloWorld.py"" failed. Exit Code: 1(General error) Working directory: D:\LabToolLaravel\public Output: ================ Error Output: ================ Fatal Python erro
The command "D:\Python\python.exe "/scripts/HelloWorld.py"" failed.
Exit Code: 1(General error) Working directory: D:\LabToolLaravel\public Output: ================ Error Output: ================
Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python Python runtime state: preinitialized
$out=new\Symfony\Component\Console\Output\ConsoleOutput();
$python=“D:\python\python.exe”;
$process=newprocess([$python,'/scripts/HelloWorld.py']);
$process->run();
如果(!$process->isSuccessful()){
抛出新的ProcessFailedException($process);
}
$out->writeln($process->getOutput());
编辑:
如果我使用shell_exec(),它会工作。我想使用Symfony,但我想现在我会使用shell_exec()
$out = new \Symfony\Component\Console\Output\ConsoleOutput();
$output = shell_exec("D:\Python\python.exe D:\Laravel\public\scripts\HelloWorld.py");
$out->writeln($output);