#
#
# .2020-06-27 09:57:59
Python
# ., 2020-06-27 09:57:59

How to find out the path of a program using Python?

I know the name of the program and I need to find out the full path to it using Python code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kulakov, 2020-06-27
@andro1

For Linux:

import subprocess

proc = subprocess.Popen('which ls', shell=True, stdout=subprocess.PIPE)
out = proc.communicate()
print(out)

Replace 'which ls' with your program 'which you_command'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question