Why does subprocess.run fail to run notepad in Win11 due to missing “package identity”, when os.system succeeds?

On Windows 10 with admin-installed Anaconda distribution, I had no problem using subprocess.run to open Notepad. However, when I now try to run the same command on Windows 11 from a user-installed Miniforge python environment, it fails with the following package identity error:

> import subprocess
> subprocess.run([r'C:\WINDOWS\notepad.exe'])
OSError: [WinError 15700] The process has no package identity

By way of contrast, os.system works fine:

> import os
> os.system(r'C:\WINDOWS\notepad.exe')
0

Does anyone have any idea why this is happening? I can run other programs (presumably because they have a “package identity”), but not “Notepad”. Other similar programs like “write.exe” and “calc.exe” work fine. I wonder if it is related to the changes they have made to Notepad for Windows 11. Is there any way to get round this?

> import subprocess
> subprocess.run([r'C:\WINDOWS\System32\write.exe'])
CompletedProcess(args=['C:\\WINDOWS\\System32\\write.exe'], returncode=0)

Leave a Comment