Skip to content

load_dotenv() UnicodeDecodeError #207

Closed

Description

@wucong60

in .evn file

app_key = '201909128757' account_name = '中国股份有限公司'
in home.py
`
from dotenv import load_dotenv, find_dotenv
import os

load_dotenv(find_dotenv())

print(os.getenv('account_name'))
`

error:

File "C:\Python37\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 447: character maps to

Activity

  1. bbc2 commented on Nov 15, 2020

    @bbc2
    Collaborator

    I can't reproduce the issue. In what encoding is your .env file and what's the default encoding on your system? You might want to try the encoding parameter of load_dotenv.

  2. SerinaNya commented on Jan 13, 2021

    @SerinaNya

    I have the same problem with the errorlog: UnicodeDecodeError: 'gbk' codec can't decode byte 0x91 in position 12: incomplete multibyte sequence
    And I succeed in solve this by the following code:

    load_dotenv(encoding='utf8')

    手动传个编码就解决了嘛~

  3. methane commented on Feb 13, 2021

    @methane
    Contributor

    How about changing default encoding from locale specific to UTF-8?

  4. andodet commented on Mar 10, 2021

    @andodet

    Probably duplicate of #300

  5. bbc2 commented on Mar 10, 2021

    @bbc2
    Collaborator

    Yes, and I think that this particular issue was resolved so let me close it.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions