Skip to content

py command fails with RC_INTERNAL_ERROR (109) return code when run with an App Pool identity in Windows #115049

Closed
@kenlyon

Description

@kenlyon

Bug report

Bug description:

I have a .NET 6 web application that responds to REST requests. Amongst other things, it can execute python scripts. This is achieved by starting a new process that uses the "py" command to execute our script.

I recently discovered that this is failing with an exit code of 109, which is described in the documentation as "Unexpected error. Please report a bug."

I had installed python 3.12.1 for all users on the host machine. I also found that when I'm debugging the application (it runs as me) it works fine, but when it's installed in IIS (running as the ApplicationPoolIdentity) it always fails with that error, even if I try to just run "py -h".

I did find that if I changed my Application Pool Identity to be "LocalSystem" it did work.

I also found that if I changed my code to execute "C:\Program Files\Python312\python.exe" it worked correctly.

It seems to be a problem with py.exe trying to discover the installed versions of python while being executed with an AppPoolIdentity.

Is this a bug in py.exe? Is there some special permission I need to grant my AppPoolIdentity on a particular folder or something?

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

Labels

OS-windowstype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions