It should display path to executable and version of Python for scripts run with direct invocation of Python (python myscript.py
) as well as for scripts run directly (myscript.py
). Script should not make too many assumptions on the configuration of the system. For instance it should handle situation where there might be no available Python.
Rationale
I'm playing with different ways of setting environment for running Python scripts and I thought it would be helpful to have a script telling me what the current configuration is. I'm concerned with the standard means provided by OS - the PATH
environment variable and association of files' types with handlers (assoc
and ftype
commands as well as PATHEXT
environment variable). This leaves pylauncher outside of the scope of this question.
This might be what you're looking for:
Here's my first solution:
SOLUTION 1
I run into problem with this, however. When there's no valid Python interpreter associated with Python files trying to open Python file with
some_script.py
pops up Open With system dialog. Solving this problem requires very good knowledge of batch files. Therefore trying to come up with a solution I've asked the following questions:Improved version of the original batch file looks now like this:
SOLUTION 1b
This is another take avoiding problems of the above two:
SOLUTION 2
... and improved version:
SOLUTION 2b