3.11 Regression, Py_Initialize; Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 领域
- api, operating-systems
调研方向
从使用 Py_Initialize 和 Python.h 的 C 程序开始,在 Windows 11 上使用 Python 3.11 重现该行为。比较使用已安装的 python311.dll、复制的 DLL 以及更早 Python 版本时的执行情况,然后调查初始化如何定位 Lib/encodings。当复制的 Python 3.11 DLL 无需单独复制 encodings 目录即可完成初始化时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Bug report
Build and run the following program;
#include <Python.h>
int main(int argc, char* argv[])
{
Py_Initialize();
return 0;
}
The resulting executable runs fine when executed against the installed C:\Program Files\Python311\python311.dll
Executing against python311.dll copied to some other folder (C:\Windows\System32 for instance) results in;
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x0000333c (most recent call first):
<no Python frame>
When also C:\Program Files\Python311\Lib\encodings is copied then the executable runs fine again.
This is not the case with Python versions prior to 3.11. The only thing needed to run Python embedded for versions below 3.11 is the appropriate pythonXXX.dll
Your environment
- CPython versions tested on:
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32 - Operating system and architecture:
Edition Windows 11 Pro
Version 21H2
Installed on 11/24/2021
OS build 22000.1098
Experience Windows Feature Experience Pack 1000.22000.1098.0 - Compiler used:
Microsoft Visual Studio Community 2022
Version 17.3.6
VisualStudio.17.Release/17.3.6+32929.385
Microsoft .NET Framework
Version 4.8.04161
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA258
Microsoft Visual C++ 2022
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 558
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python/cpython 的其他 Issue
-
docs pending
难度 2/5 1-3 小时 新手友好度 78/100
-
stdlib type-feature
难度 2/5 1-3 小时 新手友好度 78/100
-
stdlib type-feature
难度 2/5 1-3 小时 新手友好度 72/100
-
build type-bug
难度 2/5 1-3 小时 新手友好度 76/100
-
stdlib topic-email type-feature
难度 2/5 1-3 小时 新手友好度 70/100
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
zostera/django-bootstrap4#894 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
use-agent-os/agent-os#3276 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#117848 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
zilliztech/memsearch#759 ·