2

I want to run Python script using "Python launcher" so that I can use shebang line to specify the Python environment for each individual script.

I installed Python 3.6 from Anaconda.

However, when I type "py" in conda prompt or windows CMD, it says 'py' is not recognized as an internal or external command.

What should I do in order to use "py" command to launch Python script?

Sean Zhang
  • 21
  • 1
  • 1
  • 4

3 Answers3

4

It looks like Anaconda does not come with the py launcher. Some workarounds here https://stackoverflow.com/a/30794388/50899.

The standard 3.x Python installers for Windows (I think from Python 3.3 and onward) have an option to also install the py launcher. See the screenshots below. As far as I know, it is even selected by default.

After that, you can include python shebang lines as documented e.g.,

Note that (as explained here):

The launcher is restricted to launching Python scripts. It is not intended as a general-purpose script launcher or shebang processor.

Screenshots:

first installer screen second installer screen

Rabarberski
  • 23,854
  • 21
  • 74
  • 96
0

Unless you are using cygwin, windows has no shebang support. However, when you install Python, it should associate .py files with Python on the command line. Try running the script by just using the script name from your command line, or double-clicking the script in explorer. If this file-type association does not exist, you should also be able to run your script using conda script.py.

J. Blackadar
  • 1,821
  • 1
  • 11
  • 18
0

You can independently download and install it from this link, source and more info on GT

Jomme
  • 1,256
  • 4
  • 14
  • 26