
Python Launcher for Windows is a utility that helps locate and execute different Python versions. It allows a script (or command line) to indicate preferences for a specific Python version and will locate and execute that version.
Unlike the PATH variable, the launcher will correctly select the most appropriate Python version. It prefers to install by user rather than system, and sorts by language version rather than using the most recently installed version.
Launchers were originally specified in PEP 397.
Several ways to start Python:
1. Start Python from the command line
Installing Python 3.3 and above globally will put the launcher on your PATH. The launcher is compatible with all available Python versions, so it doesn't matter which version is installed. To check if the launcher is available, execute the following command in the command prompt:
py
will find that the latest version of Python installed is started - it can exit normally, and any other command line arguments specified will be Sent directly to Python.
If you have multiple versions of Python installed (for example, 2.7 and 3.7), you will notice that Python 3.7 starts - If you want to start Python 2.7, try the command:
py -2.7
If you want To use the latest version of Python 2.x, try the following command:
py -2
You will find that the latest version of Python 2.x has started.
If you see the following error, you do not have the launcher installed:
'py' is not recognized as an internal or external command, operable program or batch file.
Single-user installations of Python will not add the launcher to the PATH unless that option is selected during installation .
2. Start Python from a script
Let’s create a test Python script - create a file called ``hello.py`` with the following content
#! python
import sys
sys.stdout.write("hello from Python %s\n" % (sys.version,))From the directory where hello.py is located, execute the following command:
py hello.py
You should notice that the version number of the latest Python 2.x installation is printed. Now try changing the first line to:
#! python3
Now, re-executing the command should print the latest Python 3.x information. As with the command line example above, you can specify the version qualifier more explicitly. Assuming you have Python 2.6 installed, try changing the first line to #! python2.6 and you will find the 2.6 version information printed.
Please note that unlike interactive use, bare "python" will use the latest version of Python 2.x you have installed. This is for backward compatibility and Unix compatibility, where the command python usually refers to Python 2.
3. Start Python from a file association
When installing, you should associate the launcher with the Python file (i.e. .py, .pyw, .pyc file) associated. This means that when you double-click one of the files from Windows Explorer, the launcher will be used, so you can use the same tool above to let the script specify which version it should use.
The main benefit of this is that a single launcher can support multiple Python versions at the same time, depending on the content of the first line.
For more Python related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of How to enable python after installation. For more information, please follow other related articles on the PHP Chinese website!
Python and Time: Making the Most of Your Study TimeApr 14, 2025 am 12:02 AMTo maximize the efficiency of learning Python in a limited time, you can use Python's datetime, time, and schedule modules. 1. The datetime module is used to record and plan learning time. 2. The time module helps to set study and rest time. 3. The schedule module automatically arranges weekly learning tasks.
Python: Games, GUIs, and MoreApr 13, 2025 am 12:14 AMPython excels in gaming and GUI development. 1) Game development uses Pygame, providing drawing, audio and other functions, which are suitable for creating 2D games. 2) GUI development can choose Tkinter or PyQt. Tkinter is simple and easy to use, PyQt has rich functions and is suitable for professional development.
Python vs. C : Applications and Use Cases ComparedApr 12, 2025 am 12:01 AMPython is suitable for data science, web development and automation tasks, while C is suitable for system programming, game development and embedded systems. Python is known for its simplicity and powerful ecosystem, while C is known for its high performance and underlying control capabilities.
The 2-Hour Python Plan: A Realistic ApproachApr 11, 2025 am 12:04 AMYou can learn basic programming concepts and skills of Python within 2 hours. 1. Learn variables and data types, 2. Master control flow (conditional statements and loops), 3. Understand the definition and use of functions, 4. Quickly get started with Python programming through simple examples and code snippets.
Python: Exploring Its Primary ApplicationsApr 10, 2025 am 09:41 AMPython is widely used in the fields of web development, data science, machine learning, automation and scripting. 1) In web development, Django and Flask frameworks simplify the development process. 2) In the fields of data science and machine learning, NumPy, Pandas, Scikit-learn and TensorFlow libraries provide strong support. 3) In terms of automation and scripting, Python is suitable for tasks such as automated testing and system management.
How Much Python Can You Learn in 2 Hours?Apr 09, 2025 pm 04:33 PMYou can learn the basics of Python within two hours. 1. Learn variables and data types, 2. Master control structures such as if statements and loops, 3. Understand the definition and use of functions. These will help you start writing simple Python programs.
How to teach computer novice programming basics in project and problem-driven methods within 10 hours?Apr 02, 2025 am 07:18 AMHow to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...
How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading?Apr 02, 2025 am 07:15 AMHow to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software






