I’m doing some test with Farm and I just want the Agent to execute a python script, but it does not work, so I tried to make it even more simple. I just want it to execute python.exe -h and save the output in a text file.
But regardles whether I run this command or if I try to execute a python script I get the error <class ‘FileNotFoundError’>: [WinError 2] from the Agent when I look in the log from the Dashboard.
ERROR: Omniverse Agent could not find a "C:\Users\********\scoop\apps\python39\3.9.13>python.exe -h > "C:\Projects\Python\output.txt"" command to execute. Additional information from the host are listed below:
<class 'FileNotFoundError'>: [WinError 2] The system cannot find the file specified
Even when I specify the absolute paths it says it can’t find the file (but I don’t know what file it is not finding).
I’ve tried executing the same commands in the Windows CMD and there it works without any issue, so there must be something with the Agent that is causing the issue?
By opening a file with the name “filename.ext” using the open() function, you are using a relative path to indicate that the file is located in the current working directory.
file = open('filename.ext') //relative path
In the code snippet above, only the name of the file is provided to the open() function, which is a relative path. If the file with the given name is not present in the working directory, it will raise a “FileNotFoundError: [Errno 2] No such file or directory” error. In such cases, using the exact or absolute path to the file can resolve the issue.
The above code uses an absolute path, which contains all the information needed to locate the file, including the root directory and any subdirectories.
If the user does not provide the full path to the file (which, on Unix systems, must start with a slash), the file path in Python is interpreted relative to the current working directory. By default, the current working directory is the directory from which you started the Python program. However, in order for this to work, the directory that contains the Python executable must be included in the system’s PATH environment variable, which specifies directories that are automatically searched for executables when a command is entered. Regardless, if your Python script and input file are located in different directories, you must either specify a relative path between them or use an absolute path for one of them.