Skip to content Skip to sidebar Skip to footer

Subprocess.run() Cannot Find Path

I have a problem with a script I wrote. I'm just trying to run an executable (I took arduino.exe as an example). However, I either get a FileNotFoundError: [WinError 2] or a non-ze

Solution 1:

you need to escape backslash character. use \\ instead of \ for every backslash,

subprocess.run("C:\\Program Files (x86)\\Arduino\\arduino.exe",shell=True,check=True)

or you can use raw string literal,

subprocess.run(r"C:\Program Files (x86)\Arduino\arduino.exe",shell=True,check=True)

Post a Comment for "Subprocess.run() Cannot Find Path"