2

How can I:

  1. Check if Python is installed on a machine and, if it is, then
  2. Get the executable path to it?

Note: I'm fine with it being Python, IronPython, etc... Just anything that I can pass a .py file and have it run it.

I could hard code some paths (e.g. C:\Program Files (x86)\Iron Python... ), but I'd like something more elegant, if it exists.

2 Answers 2

3

Probably not what you're looking for but the Powershell Cmdlet get-command outputs the full executable path. For example:

get-command python | ForEach-Object -Process {write-host $_.Definition}
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for the idea, but I'll need to do this on each user's computer and installing PowerShell on their computers isn't an option.
Helped me when I needed to find which python executable PowerShell uses!
1

Examining this registry key works alright:

HKEY_CLASSES_ROOT\Python.File\shell\open\command

If it's not there, then I just ask the user.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.