question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] UnicodeEncodeError upon dynaconf init

See original GitHub issue

Describe the bug

dynaconf init -f yaml results in a UnicodeEncodeError

To Reproduce Steps to reproduce the behavior:

  1. git clone -b dynaconf https://github.com/ebenh/django-flex-user.git
  2. py -m pipenv install --dev
  3. py -m pipenv shell
  4. export DJANGO_SETTINGS_MODULE=test_project.settings
  5. 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
endersonmenezescommented, Oct 8, 2021

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:

  • Emojis removed where they don’t work.
  • Emojis working for those who like to put emojis on everything (like me) 😄

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

1reaction
endersonmenezescommented, Oct 7, 2021

image

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found