using the subprocess library package, is there a way to run an executable by providing its absolute path? I know that you can run the following apps without it:
import subprocess
subprocess.run('notepad')
# or
subprocess.run('start winword', shell=True)
# or
subprocess.run('start excel', shell=True)
Is there a way to call / open an application using its absolute path?
For example, C:\Program Files\JetBrains\PyCharm Community Edition 2024.2.1\bin\pycharm64.exe
Use a raw string literal to avoid expanding escape sequences like \b in the file name. I’d also recommend passing the command as a list (not a single string) with shell=False (the default) unless you know what you’re doing and want an intermediate shell process.
subprocess.run([r'C:\Program Files\JetBrains\PyCharm Community Edition 2024.2.1\bin\pycharm64.exe'])
See Frequently Used Arguments from the docs for more on how the command argument is process and what shell=True does.