24

I'm trying to use different versions of Python on Windows 7, and I was told that I can use the "Python launcher"

But where is this program? I heard it should be called py.exe, but there is no file with this name on my computer. Where should it be? If I don't have it, how can I install it?

1
  • For those who are looking for where py.exe is located,you can use where py in cmd Commented Mar 19, 2020 at 6:56

4 Answers 4

20

It should be in the root directory of Python 3.3 installs and higher. It is not available for Python2.

Go to C:\PythonXX\ and you should find py.exe for your version.

In Command Prompt or your favorite shell (like Cygwin), run:

py -3.3 -m path/to/myscript.py

However, this only works if you have a 3.3 or higher installed.

Note that Anaconda does not come with Python launcher. However, it will work to set Anaconda as your default install for Python 3.4 and install py.exe separately. For example, you can install Python 3.4 from another source, copy its py.exe to somewhere on the system path, and uninstall Python 3.4 again; then the python launcher is fully installed.

Better yet, there's a standalone installer available here.

Sign up to request clarification or add additional context in comments.

7 Comments

Hmm, your answer seems perhaps more useful than mine - not sure why it was downvoted.
Then how can I install it? And is there anyother good distribution? I really like Anaconda comes with Scipy, makes python much more accssible for laymen like me.
There's a standalone installer available here: bitbucket.org/vinay.sajip/pylauncher/downloads
This answer is ... blatantly not correct. The Python installer(s) put py.exe in %SYSTEMROOT%.
@Will, This answer is nearly 3 years old and tools change in much shorter periods. If information has changed in that time, you are free to update it with newer versions of software, or write a comment so I may do so. Your aggressive post stating that the information is blatantly incorrect completely ignores the time at which it was posted.
|
17

If installing the Python interpreter from python.org's downloads and you select "[x] install pylauncher [x] install for all users", py.exe is installed in C:\Windows\py.exe (%SystemRoot%\py.exe).

If you are able to run py from cmd.exe, then you can find out where it is with where py.exe.

Comments

4

When Python is not installed "for all users", the launcher goes to an %APPDATA% subdirectory:

C:\Users\{your username}\AppData\Local\Programs\Python\Launcher\py.exe

Tested with Python 3.11.3.

2 Comments

C:\Users\XXXX\AppData\Local\Programs\Python\Python311
I'm not on Windows, but I'm pretty sure @OsamaHussein is correct that there will be another subfolder for the specific Python version. Could you please double-check this?
3

It looks like the Python executable is part of the conda command if you're using Anaconda, according to their website. According to Alexander Huszagh (see his answer), the Python launcher doesn't come with Anaconda Python.

Here is a blog post that is perhaps relevant.

3 Comments

No. The Python launcher is py.exe which is found main directory in the standard install, as well as the ActiveState Python installs for Python 3.3 and later.
It doesn't come default, by the way.
"It looks like the python executable is part of the conda command", that would make sense as conda is used to select which "virtual" environment is activated (actually these virtual environments seem to be plain and redundant installations). How can the two cohabit? I wonder if life wouldn't be easier if conda was limited to configuration management, and the python launcher always used to select the right environment based on shebang lines.

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.