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.

UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-79: character maps to <undefined>

See original GitHub issue
  • safety version: 1.7.0
  • Python version: Python 3.6.1
  • Operating System: Windows-10-10.0.16299-SP0, AMD64

Description

  • Trying to use safety check
  • Same error always results: UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-79: character maps to <undefined>

What I Did

safety check -r simple-requirements.txt

Contents of simple-requirements.txt

safety
  • There are absolutely no unicode characters in this file

Traceback

$ safety check -r simple-requirements.txt
Warning: unpinned requirement 'safety' found in simple-requirements.txt, unable to check.
Traceback (most recent call last):
  File "c:\users\nicholas\appdata\local\programs\python\python36\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\nicholas\appdata\local\programs\python\python36\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\nicholas\.virtualenvs\pybotics-d30fj9Hx\Scripts\safety.exe\__main__.py", line 9, in <module>
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\safety\cli.py", line 66, in check
    key=key
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\click\termui.py", line 420, in secho
    return echo(style(text, **styles), file=file, nl=nl, err=err, color=color)
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\lib\site-packages\click\utils.py", line 259, in echo
    file.write(message)
  File "c:\users\nicholas\.virtualenvs\pybotics-d30fj9hx\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-79: character maps to <undefined>

Similar Issues

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
shahhacommented, Nov 11, 2019

In my case, export PYTHONIOENCODING=UTF-8 solved my issue.

1reaction
janusheidecommented, Mar 26, 2020

Thanks for you quick response and shedding some light on the problem! To me just using a conforming character is the simpler, faster and more future prof approach, so that would get my vote 😃

If there is something I can do to help, please let me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnicodeEncodeError: 'charmap' codec can't encode characters
I was getting the same UnicodeEncodeError when saving scraped web content to a file. To fix it I replaced this code:
Read more >
UnicodeEncodeError: 'charmap' codec can't encode character ...
UnicodeEncodeError : 'charmap' codec can't encode character u'\u2026' in position 139: character maps to <undefined> #1. Open. baditaflorin opened this issue on ...
Read more >
UnicodeEncodeError: 'charmap' codec can't ... - Code Grepper
Queries related to “UnicodeEncodeError: 'charmap' codec can't encode character '\u200b' in position 85: character maps to <undefined>”.
Read more >
UnicodeEncodeError: 'charmap' codec can't encode ...
INTERNALERROR occurs running pytest - "UnicodeEncodeError: 'charmap' codec can't encode characters in position ...: character maps to <undefined>" · Workaround.
Read more >
'charmap' codec can't encode character... - YouTube
SOLVED #PYTHON #ERROR UnicodeEncodeError : ' charmap ' codec can't encode character '\u266b' in position 157411: character maps to undefined ...
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