Skip to content

Update PATHEXT environment variable as configuration step #373

@Bill-Stewart

Description

@Bill-Stewart

I installed the Python Install Manager on a Windows 11 machine that never had it installed before.

Next, I created a short program, hello.py, containing a single print function:

print('Hello, world')

In a new PowerShell terminal window, I ran it:

PS C:\Users\username\Scripts> .\hello.py

Windows spawns a separate terminal window to run it, which closes immediately. As noted in #193 this is currently "just how it works," but there seems to be a better way: Update the PATHEXT environment variable to include Python filename extensions where the user can reasonably expect that the Python program will run in the current terminal:

PS C:\Users\username\Scripts> $env:PATHEXT += ";.PY"
PS C:\Users\username\Scripts> .\hello.py
Hello, world

After adding .PY to PATHEXT and running hello.py by name, it ran in the current terminal window.

Accordingly, it would seem sensible to add a configuration step that adds .PY (and anything else appropriate) to the PATHEXT environment variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions