0

I am trying to get the install location of conda. This works fine on Windows:

conda_path = subprocess.check_output('where anaconda').decode("utf-8").strip()

In a linux shell whereis conda works. os.system("whereis conda") returns zero.

However,

conda_path = subprocess.check_output('where anaconda').decode("utf-8").strip()

Fails with: FileNotFoundError: [Errno 2] No such file or directory: 'whereis conda': 'whereis conda'

Any suggestions?

Koedlt
  • 4,286
  • 8
  • 15
  • 33
illan
  • 163
  • 1
  • 13

1 Answers1

1

If you pass a single string, you need a shell to parse it into the command name and its arguments: subprocess.check_output('where anaconda', shell=True)....

Otherwise, you need to provide a list where the command name and each argument is a separate element. (One of the primary jobs of a shell is to do precisely that parsing.)

conda_path = subprocess.check_output(['where', 'anaconda']).decode("utf-8").strip()
chepner
  • 497,756
  • 71
  • 530
  • 681