[bug] UnicodeEncodeError upon dynaconf init
See original GitHub issueDescribe the bug
dynaconf init -f yaml
results in a UnicodeEncodeError
To Reproduce Steps to reproduce the behavior:
git clone -b dynaconf https://github.com/ebenh/django-flex-user.git
py -m pipenv install --dev
py -m pipenv shell
export DJANGO_SETTINGS_MODULE=test_project.settings
dynaconf init -f yaml
Error Message
Traceback (most recent call last):
File "C:\Users\eben\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\eben\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\eben\.virtualenvs\django-flex-user-ab_cVlY8\Scripts\dynaconf.exe\__main__.py", line 7, in <module>
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\vendor\click\core.py", line 221, in __call__
def __call__(A,*B,**C):return A.main(*B,**C)
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\vendor\click\core.py", line 205, in main
H=E.invoke(F)
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\vendor\click\core.py", line 345, in invoke
with C:return F(C.command.invoke(C))
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\vendor\click\core.py", line 288, in invoke
if A.callback is not _A:return ctx.invoke(A.callback,**ctx.params)
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\vendor\click\core.py", line 170, in invoke
with G:return A(*B,**E)
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\vendor\click\decorators.py", line 21, in A
def A(*A,**B):return f(get_current_context(),*A,**B)
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\cli.py", line 257, in init
click.echo("\u2699\ufe0f Configuring your Dynaconf environment")
File "c:\users\eben\.virtualenvs\django-flex-user-ab_cvly8\lib\site-packages\dynaconf\vendor\click\utils.py", line 82, in echo
if A:B.write(A)
File "C:\Users\eben\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character maps to <undefined>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (7 by maintainers)
Top Results From Across the Web
[bug] UnicodeEncodeError upon dynaconf init #664 - GitHub
Describe the bug dynaconf init -f yaml results in a UnicodeEncodeError To Reproduce Steps to reproduce the behavior: git clone -b dynaconf ......
Read more >dynaconf/dev - Gitter
@rochacbruno:matrix.org When I execute all tests, I receive this error: ... /home/river/Documents/projects/pessoais/dynaconf/tests/test_base.py:214: in ...
Read more >Dynaconf - 3.1.11
In your project's root directory run dynaconf init command. ... ℹ️ You can choose toml|yaml|json|ini|py on dynaconf init -f <fileformat> , toml is...
Read more >Add dynaconf - Guix issue tracker
on 30 Jun 2021 00:38 ... + dynaconf/vendor_src/ruamel/yaml/__init__.py | 60 - ... +- report in Python2, instead of raising a Unicode error.
Read more >Configuration Handling — Flask Documentation (2.2.x)
When using flask run to start the development server, an interactive debugger will be shown for unhandled exceptions, and the server will be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think we can keep the emojis and use PYTHONIOENCODING, as our String is passed by IO, just when it’s not able to decode it will remove it, so we have the two solutions:
I think
os.environ["PYTHONIOENCODING"] = "utf-8"
the change will not change anything for newer devices that already have this by default, and helps users more, makes a learning curve for using dynaconf shorter, i can make a PR?EDIT: The result would be similar to this change, simpler. https://github.com/pypa/pipenv/pull/3132/files
This issue seems to have been fixed in latest Windows updates. https://github.com/microsoft/terminal/issues/190
I’m researching if this fix is only in Newer Builds. (I’m using Windows 11), and seeing how we can work around to not break the execution in older builds.
@ebenh What your windows version for me reproduce this in Virtual Machine?