You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UnicodeDecodeError exception occurs when .env file contains Non-ASCII characters on Windows #175
When .env file contains Non-ASCII characters, for example:
foo=bar
# 测试
or
foo=测试
It will cause UnicodeDecodeError: 'gbk' codec can't decode bytes in position 25-26: illegal multibyte sequence.
Tested on macOS and Windows, this problem only happened on Windows (both Python 2.7 and Python 3.6).
Here is the full error traceback:
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_codeexec code in run_globals
File "C:\Python27\Scripts\flask.exe\__main__.py", line 9, in <module>
File "c:\python27\lib\site-packages\flask\cli.py", line 894, in main
cli.main(args=args, prog_name=name)
File "c:\python27\lib\site-packages\flask\cli.py", line 548, in main
load_dotenv()
File "c:\python27\lib\site-packages\flask\cli.py", line 608, in load_dotenv
dotenv.load_dotenv(path)
File "c:\python27\lib\site-packages\dotenv\main.py", line 309, in load_dotenvreturn DotEnv(f, verbose=verbose).set_as_environment_variables(override=override)
File "c:\python27\lib\site-packages\dotenv\main.py", line 129, in set_as_environment_variablesfor k, v inself.dict().items():
File "c:\python27\lib\site-packages\dotenv\main.py", line 115, in dict
values = OrderedDict(self.parse())
File "c:\python27\lib\collections.py", line 69, in __init__self.__update(*args, **kwds)
File "c:\python27\lib\_abcoll.py", line 571, in updatefor key, value in other:
File "c:\python27\lib\site-packages\dotenv\main.py", line 121, in parsefor mapping in parse_stream(stream):
File "c:\python27\lib\site-packages\dotenv\main.py", line 83, in parse_stream
string = stream.read()
UnicodeDecodeError: 'gbk' codec can't decode bytes in position 25-26: illegal multibyte sequence
changed the title [-]UnicodeDecodeError: 'gbk' codec can't decode bytes in position 25-26: illegal multibyte sequence occurs when comment contains Non-ASCII characters on Windows[/-]on Apr 22, 2019
Activity
[-]UnicodeDecodeError: 'gbk' codec can't decode bytes in position 25-26: illegal multibyte sequence occurs when comment contains Non-ASCII characters on Windows[/-][-]UnicodeDecodeError exception occurs when comment contains Non-ASCII characters on Windows[/-]greyli commentedon Apr 22, 2019
This issue will be fixed with #161, closing it now.
BackMountainDevil commentedon Jan 25, 2021
Package Version
Flask 1.1.2
pip 20.3.3
python-dotenv 0.15.0
python 3.9.0
windowsOS 10
still got this problem
bbc2 commentedon Jan 25, 2021
Do you get the exact same error? If not, could you post a detailed description of the problem, including the stack trace you get, in a new issue?