Skip to content

Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001. #51690

Closed

Description

@lieryan
mannequin
BPO 7441
Nosy @vstinner, @florentx
Superseder
  • bpo-6501: Fatal error on startup with invalid PYTHONIOENCODING
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-01-09.09:51:48.979>
    created_at = <Date 2009-12-05.10:40:56.645>
    labels = ['interpreter-core', 'expert-IO', 'expert-unicode', 'OS-windows', 'type-crash']
    title = 'Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001.'
    updated_at = <Date 2011-10-26.23:49:44.453>
    user = 'https://bugs.python.org/lieryan'

    bugs.python.org fields:

    activity = <Date 2011-10-26.23:49:44.453>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-01-09.09:51:48.979>
    closer = 'georg.brandl'
    components = ['Interpreter Core', 'Unicode', 'Windows', 'IO']
    creation = <Date 2009-12-05.10:40:56.645>
    creator = 'lieryan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 7441
    keywords = []
    message_count = 4.0
    messages = ['95987', '95989', '96674', '146470']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'lieryan', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '6501'
    type = 'crash'
    url = 'https://bugs.python.org/issue7441'
    versions = ['Python 3.1']

    Activity

    1. lieryan commented on Dec 5, 2009

      lieryanmannequin
      MannequinAuthor

      maybe related to bpo-6501

      Vista 32-bit SP1, Python 3.1:
      """
      Microsoft Windows [Version 6.0.6000]
      Copyright (c) 2006 Microsoft Corporation. All rights reserved.
      D:\>chcp 65001
      Active code page: 65001

      D:\>python -c 'print("")'
      Fatal Python error: Py_Initialize: can't initialize sys standard streams
      LookupError: unknown encoding: cp65001

      This application has requested the Runtime to terminate it in an unusual
      way.
      Please contact the application's support team for more information.
      D:\>python
      Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
      (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.

      >>
      """

      Expected, either:

      1. print nothing (""), or
      2. python exception about unknown encoding, or
      3. python exception about cannot encode to the encoding

      cp65001 is supposed to be an alias for utf-8. Because of the error,
      there is AFAICT no way to set the command prompt to accept utf-8 output
      even for pipe redirection.

      A workaround is to use sys.stdout.buffer.write() to write raw byte
      strings, encoding manually. But this takes us back to python 2.

    2. florentx commented on Dec 5, 2009

      florentxmannequin
      Mannequin

      there's a patch proposed to add cp65001 alias: bpo-6058

    3. florentx commented on Dec 20, 2009

      florentxmannequin
      Mannequin

      Thank you for your report.
      See bpo-6501 about the Fatal Error
      See bpo-6058 for the feature request (cp65001 on windows).

    4. vstinner commented on Oct 26, 2011

      @vstinner
      Member

      I added a cp65001 codec to Python 3.3: see issue bpo-13216. So Python will not "crash" anymore if the console code page is set to cp65001.

    5. transferred this issue fromon Apr 10, 2022
    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

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions