Code Monkey home page Code Monkey logo

Comments (14)

shahha avatar shahha commented on June 2, 2024 11

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

from safety.

guidoavvisati avatar guidoavvisati commented on June 2, 2024 1

Still not fixed, but the workaround from @shahha works for me as well

from safety.

janusheide avatar janusheide commented on June 2, 2024 1

Still experience this error

Using safety 1.8.7
On a github windows-latest runner (https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md)

I get the following:

Traceback (most recent call last):
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\hostedtoolcache\windows\Python\3.7.6\x64\Scripts\safety.exe\__main__.py", line 7, in <module>
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\safety\cli.py", line 89, in check
    click.secho(output_report, nl=False if bare and not vulns else True)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\click\termui.py", line 548, in secho
    return echo(message, file=file, nl=nl, err=err, color=color)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\click\utils.py", line 272, in echo
    file.write(message)
  File "c:\hostedtoolcache\windows\python\3.7.6\x64\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>

from safety.

janusheide avatar janusheide commented on June 2, 2024 1

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.

from safety.

jayfk avatar jayfk commented on June 2, 2024

That's odd. I tried to reproduce this locally on different windows environments but wasn't able to.

It looks like the output is the problem here: https://github.com/pyupio/safety/blob/master/safety/formatter.py#L48

from safety.

jayvdb avatar jayvdb commented on June 2, 2024

This is probably a dup of #22

and is likely fixed by #36

from safety.

jayvdb avatar jayvdb commented on June 2, 2024

@nnadeau, is this fixed for you now?

from safety.

engnadeau avatar engnadeau commented on June 2, 2024

I'll check asap when I get access to a Windows PC

from safety.

rahulrajaram avatar rahulrajaram commented on June 2, 2024

My Jenkins Windows builds fail with this error only against Python 3.5-3.7. This is not an issue with Python 2.7 or Python 3.4.

I am unable to reproduce this issue on the same machine using the same Python executables as a regular user.

from safety.

leowonglaw avatar leowonglaw commented on June 2, 2024

I had the same issue when I used git bash insted of CMD. With CMD it works fine.

from safety.

Midnighter avatar Midnighter commented on June 2, 2024

I'm seeing this error using Miniconda on AppVeyor. See the build log.

You can inspect the repo and configuration here.

from safety.

radeklat avatar radeklat commented on June 2, 2024

I'm hitting the same issue on Python 3.7.4 when running MinGW (GitBash) and also in cygwin bash but in that instance only when running it in a sub-shell as $(safety check -r requirements.txt)

from safety.

rafaelpivato avatar rafaelpivato commented on June 2, 2024

I know this has been around for quiet a while now, but I would need another feedback from anyone who is still experiencing this with latest version. If you do, please write me down your Safety version, your operating system and your complete stack trace.

from safety.

rafaelpivato avatar rafaelpivato commented on June 2, 2024

@janusheide thank you very much for such details. That confirmed my hypothesis. This stack trace confirms the error was dumping a report to standard output:

  File "c:\hostedtoolcache\windows\python\3.7.6\x64\lib\site-packages\safety\cli.py", line 89, in check
    click.secho(output_report, nl=False if bare and not vulns else True)

Our JSON Formater is using a special character to draw the framing that is not being mapped properly. This console session shows the issue:

In [1]: import codecs                                                                                                      

In [2]: codecs.encode('═' * 7, encoding='cp1252')                                                                          
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-2-4656467a13d4> in <module>
----> 1 codecs.encode('═' * 7, encoding='cp1252')

/usr/lib/python3.7/encodings/cp1252.py in encode(self, input, errors)
     10 
     11     def encode(self,input,errors='strict'):
---> 12         return codecs.charmap_encode(input,errors,encoding_table)
     13 
     14     def decode(self,input,errors='strict'):

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

So, we need some code that will either decode properly or just change that ASCII art to not use non-ASCII characters. My preference is towards the second option, which should cause less issues.

from safety.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.