We met problem with running python file. I am not sure if we have did wrong with any environment setting.
ArcGIS Pro 2.8 installed with arcpy
1. A c# API calls a batch file
2. Then, the batch file calls a python script
Problem happened that it all failed with no return when arcpy import included. But, we can run successfully with no arcpy included. So, we verified that python can be executed when without arcpy.
Code for c# API
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
//start.WorkingDirectory = @"D:\script",
FileName = @"D:\script\pythontest.bat",
Arguments = "",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
string output = p.StandardOutput.ReadToEnd();
Log.Information("python output=" + output);
Code for pythontest.bat batch file
"C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\propy" myscript.py
Code for myscript.py
What license do you have for the Pro installation? arcpy also has to be licensed, so it may be failing on not being able to be licensed. You can wrap the imports into a try/except and log the exception that happens when it tries to import arcpy.