Skip to content

Calling 'py' from other languages calls invalid path to 'py' #99587

Closed as not planned
@vlad-emelyanov

Description

@vlad-emelyanov

Crash report

The Python Launcher (version 3.11.7966.0) that comes with Python 3.11.0 crashes because it resolves 'py' to a path that doesn't exist (C:\Users{USERNAME}\AppData\Local\Programs\Python\Python311\py) when launched as a subprocess from another programming language (tested in C# and Rust). It appears to look for py.exe in the installation location of python.exe, however 'py.exe' is not present there. The below error is thrown even if Python 3.11.0 is uninstalled (leaving only Python 3.10.5) but the 3.11 launcher is still present. This error does not get thrown by the 3.10 or earlier launcher (even if Python 3.11 is installed). This is 10/10 reproducible on every Windows machine we've tested on. This is not reproducible by calling 'py' directly on the command line, or with a Python 'subprocess.Popen()' call.

Reproduction steps:

  1. Install the Python 3.11.0 x64 Windows installer, including the Python launcher
  2. Run the following sample C# program

using System.Diagnostics;

namespace TestApp {
class Program {
static void Main(string[] args) {
var p = new Process {
StartInfo = {
FileName = "py",
ArgumentList = { "--version" },
}
};
p.Start();
p.WaitForExit();
}
}
}

Error messages

Unable to create process using 'C:\Users\vemelyanov\AppData\Local\Programs\Python\Python311\py" --version': The system cannot find the file specified.

This error seems to come from the launcher itself, not the executing program (i.e. C# or Rust). If the C# program above calls a command that actually doesn't exist on the system, it will throw a 'System.ComponentModel.Win32Exception (2): The system cannot find the file specified.' instead of logging the above message.

Your environment

  • CPython versions tested on: 3.10.5, 3.11.0
  • Operating system and architecture: Window

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowspendingThe issue will be closed if no feedback is providedtype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions