3.11 Regression, Py_Initialize; Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding

Aberta
#99,004 7 comentários 2 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
c, python

Direção de pesquisa

Comece com o programa em C que usa Py_Initialize e Python.h, reproduzindo o comportamento no Windows 11 com Python 3.11. Compare a execução com a python311.dll instalada, uma DLL copiada e versões anteriores do Python; em seguida, investigue como a inicialização localiza Lib/encodings. Considera-se concluído quando a DLL copiada do Python 3.11 consegue inicializar sem copiar separadamente o diretório encodings.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

3.11 OS-windows type-bug

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
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Merge médio
1d 9h
PRs com merge (30d)
558

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python/cpython

Todas as issues de python/cpython

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.