Skip to content

test.pythoninfo fails on Windows in Azure CI #148750

Closed

Description

@StanFromIreland

Bug report

Bug description:

From the logs:

.\python.exe -m test.pythoninfo
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\6b4b980f-daec-4173-8a8e-2525de58013c.cmd""
WARN: Could not find the platform standard library directory! The Python 'home' directory was set to 'D:\\a\\1\\b\\layout-embed-amd64', is this correct?
ERROR: collect_windows() failed
Traceback (most recent call last):
  File "test\pythoninfo.py", line 1093, in collect_info
  File "test\pythoninfo.py", line 951, in collect_windows
  File "subprocess.py", line 1084, in __init__
LookupError: unknown encoding: oem

Collection failed: exit with error

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. zooba commented on Apr 20, 2026

    @zooba
    Member

    This looks like it's unable to find/import encodings.oem from a zipped stdlib (the unique aspect of the embeddable layout that's being tested here). I don't have time to dig right in right now, but hopefully that's a helpful starting point.

  2. added a commit that references this issue on May 16, 2026
  3. removed
    testsTests in the Lib/test dir
    on Aug 11, 2026
  4. chris-eibl commented on Aug 11, 2026

    @chris-eibl
    Member

    I can reproduce the failure beginning with 3.15.0b1:

    C:\>python-3.15.0b1-embed-amd64\python.exe
    WARN: Could not find the platform standard library directory! The Python 'home' directory was set to 'E:\\python\\python-3.15.0b1-embed-amd64', is this correct?
    Python 3.15.0b1 (tags/v3.15.0b1:f31a89b, May  7 2026, 13:53:53) [MSC v.1950 64 bit (AMD64)] on win32
    >>> import encodings
    >>> encodings
    <module 'encodings' (frozen)>
    >>> import encodings.oem
    Traceback (most recent call last):
      File "<python-input-2>", line 1, in <module>
        import encodings.oem
    ModuleNotFoundError: No module named 'encodings.oem'. Site initialization is disabled, did you forget to add the site-packages directory to sys.path or to enable your virtual environment?
    

    I think this is related to partially freezing the encodings module: #148347

    I furthermore do not think the closed duplicate #155254 is related, since this other issue started with 3.15.0a7, which can load encodings.oem, and only issues that warning on startup:

    C:\>python-3.15.0a7-embed-amd64\python.exe
    WARN: Could not find the platform standard library directory! The Python 'home' directory was set to 'E:\\python\\python-3.15.0a7-embed-amd64', is this correct?
    Python 3.15.0a7 (tags/v3.15.0a7:6024d3c, Mar 10 2026, 13:09:10) [MSC v.1944 64 bit (AMD64)] on win32
    >>> import encodings.oem
    >>> encodings
    <module 'encodings' from 'E:\\python\\python-3.15.0a7-embed-amd64\\python315.zip\\encodings\\__init__.pyc'>
    >>> encodings.oem
    <module 'encodings.oem' from 'E:\\python\\python-3.15.0a7-embed-amd64\\python315.zip\\encodings\\oem.pyc'>
    >>>
    
  5. zooba commented on Aug 17, 2026

    @zooba
    Member

    So do we think we need to unfreeze encodings, since it breaks zipimport of submodules? Or is there another way to solve this? (I still haven't looked yet - asking first while I catch up on everything)

  6. zooba commented on Aug 18, 2026

    @zooba
    Member

    The frozen encodings.__path__ appears to assume that the stdlib will be on disk, I haven't quite figured out how or why (whether it's hardcoded), but it has the value even when the normal Lib directory isn't on sys.path.

    Updating encodings.__path__[:] = [f"{zip file}\\encodings"] fixes it. So it's in this __path__ calculation somewhere.

  7. zooba commented on Aug 18, 2026

    @zooba
    Member

    Looking at the timing, I agree that #145278 is the culprit.

    @FFY00 any preference between reverting the encodings freeze again or figuring out a way to fix it? It looks like your guess on one of the PRs that non-frozen submodules can't be reliably imported is the problem, and while patching __path__ is a fix, I can't see an efficient way to do that.

  8. zooba commented on Aug 18, 2026

    @zooba
    Member

    FTR, I have added a hack to https://github.com/python/pymanager/pull/397/changes to work around this for a PyManager update.

  9. chris-eibl commented on Aug 18, 2026

    @chris-eibl
    Member

    For the already released embeddable packages -X frozen_modules=off is a workaround:

    e:\python\python-3.15.0rc1-embed-amd64>python.exe -X frozen_modules=off
    WARN: Could not find the platform standard library directory! The Python 'home' directory was set to 'e:\\python\\python-3.15.0rc1-embed-amd64', is this correct?
    Python 3.15.0rc1 (tags/v3.15.0rc1:37e98da, Aug  4 2026, 11:37:18) [MSC v.1951 64 bit (AMD64)] on win32
    >>> import encodings
    >>> encodings
    <module 'encodings' from 'e:\\python\\python-3.15.0rc1-embed-amd64\\python315.zip\\encodings\\__init__.pyc'>
    >>> import encodings.oem
    >>> encodings
    <module 'encodings' from 'e:\\python\\python-3.15.0rc1-embed-amd64\\python315.zip\\encodings\\__init__.pyc'>
    >>>
    
  10. zooba commented on Aug 18, 2026

    @zooba
    Member

    Yeah, but I like the startup speed 😉 It also need to be set from the initialization functions, not the command line, since we generally don't use python.exe when embedding.

  11. added a commit that references this issue on Aug 24, 2026
  12. marcelotduarte commented on Aug 26, 2026

    @marcelotduarte

    So do we think we need to unfreeze encodings, since it breaks zipimport of submodules? Or is there another way to solve this? (I still haven't looked yet - asking first while I catch up on everything)

    In cx_Freeze, I saw two options: a __path__ hack or embedding the entire encodings package. I opted for the second option.

  13. added a commit that references this issue on Aug 27, 2026
  14. added a commit that references this issue on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions