Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Using "open" command with python application...

Discussion in 'Editor & General Support' started by justin_kasowski, Jun 29, 2021.

  1. justin_kasowski

    justin_kasowski

    Joined:
    Jan 14, 2020
    Posts:
    45
    On my personal computer and campus computer, the following code works (runs the python application 'buildp2p.py' :
    Code (CSharp):
    1. if (VariableManagerScript.Instance.calculateAxonMap)
    2.             {
    3.                 ProcessStartInfo processStartInfo = new ProcessStartInfo();
    4.                 processStartInfo.FileName = "open";
    5.                 processStartInfo.UseShellExecute = false;
    6.                 processStartInfo.RedirectStandardOutput = false;
    7.                 processStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
    8.                 processStartInfo.CreateNoWindow = false;
    9.                
    10.                 string pulse2perceptCmdCall = "python " + pythonPath+"build-p2p.py " +
    11.                                   pythonPath
    12.                                   + " " + BackendShaderHandler.Instance.simulation_xMin + " " + BackendShaderHandler.Instance.simulation_xMax + " " + BackendShaderHandler.Instance.simulation_yMin + " " +
    13.                                   BackendShaderHandler.Instance.simulation_yMax + " " + BackendShaderHandler.Instance.simulation_xyStep + " " + VariableManagerScript.Instance.rho + " " + VariableManagerScript.Instance.lambda +
    14.                                   " " + VariableManagerScript.Instance.axonContributionThreshold + " " + VariableManagerScript.Instance.number_axons + " " + VariableManagerScript.Instance.number_axon_segments + " " + VariableManagerScript.Instance.useLeftEye;
    15.                 UnityEngine.Debug.Log(pulse2perceptCmdCall);
    16.                 processStartInfo.Arguments = pulse2perceptCmdCall;
    17.                
    18.                 Process process = Process.Start(processStartInfo);
    19.                 process.WaitForExit();
    20.                 UnityEngine.Debug.Log("Done waiting");
    21.                
    22.             }
    Debug of the call prints this:
    upload_2021-6-28_16-36-27.png

    On someone else's windows 10 machine, an error pops up when calling that exact command with a different path for their machine (ie. "python C:/Users/chtun/OneDrive/Documents/UCSB_RMP_BionicVisionLabProject/UCSB_RMP_Bionic_Vision_Lab_Project/Assets\BionicVisionVR\Coding\python\build-p2p.py C:/Users/chtun/OneDrive/Documents/UCSB_RMP_BionicVisionLabProject/UCSB_RMP_Bionic_Vision_Lab_Project/Assets\BionicVisionVR\Coding\python\ -17.14706 17.14706 -17.14706 17.14706 0.6470588 100 50 0.0001 300 300 False"):

    Win32Exception: ApplicationName='open', CommandLine='python C:/Users/chtun/OneDrive/Documents/UCSB_RMP_BionicVisionLabProject/UCSB_RMP_Bionic_Vision_Lab_Project/Assets\BionicVisionVR\Coding\python\build-p2p.py C:/Users/chtun/OneDrive/Documents/UCSB_RMP_BionicVisionLabProject/UCSB_RMP_Bionic_Vision_Lab_Project/Assets\BionicVisionVR\Coding\python\ -17.14706 17.14706 -17.14706 17.14706 0.6470588 100 50 0.0001 300 300 False', CurrentDirectory='', Native error= The system cannot find the file specified.

    The weird part is, the command works if he copy/pastes into a command prompt (including storing the result files in the Unity Assets folder).

    Any idea why Unity is failing to call python properly on his machines?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    open
    is a MacOSX shell shortcut to launch a MacOSX process.

    On Windows the closest equivalent is
    start
    but they are not fully interchangeable.

    If the above is from Windows, maybe you have an
    open
    replacement?
     
  3. justin_kasowski

    justin_kasowski

    Joined:
    Jan 14, 2020
    Posts:
    45
    Thank you for the reply. I think we got it figured out... After he restarted his computer it ended up working. I believe there was something cached somewhere with the project path and initially he had spaces. He replaced them with underscores but it was still calling the old path, even when he had completely closed and restarted Unity.
     
    Kurt-Dekker likes this.