Comments (14)
In my case, export PYTHONIOENCODING=UTF-8 solved my issue.
from safety.
Still not fixed, but the workaround from @shahha works for me as well
from safety.
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.
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.
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.
This is probably a dup of #22
and is likely fixed by #36
from safety.
@nnadeau, is this fixed for you now?
from safety.
I'll check asap when I get access to a Windows PC
from safety.
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.
I had the same issue when I used git bash insted of CMD. With CMD it works fine.
from safety.
I'm seeing this error using Miniconda on AppVeyor. See the build log.
You can inspect the repo and configuration here.
from safety.
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.
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.
@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)
- Checking projects using Poetry >= 1.5.0 fails HOT 3
- Vulnerability not ignored when added to .safety-policy.yml HOT 4
- Vulnerable dependecy to setuptools!?
- check --bare still outputs announcements HOT 2
- Links to Vulnerability All Broken HOT 3
- return code is 0 even though nothing was checked
- Document timeouts and make them configurable
- Not ignoring based on policy file HOT 1
- Conflict between safety report vs Debian/Ubuntu report
- safety fails on prompt-toolkit HOT 3
- Conflict with the pyjwt package HOT 1
- safety-schemas repo? HOT 2
- dependency on old pydantic causes conflicts with other packages HOT 15
- safety 3.0.0 dependencies require exact versions
- Tests fail using Pydantic v2 HOT 1
- Python 3.12.1 could not find a version that satisfies the requirement safety (from versions: none) HOT 1
- AttributeError: 'NoneType' object has no attribute 'is_using_auth_credentials' HOT 1
- Release 3.0.0 requirement pydantic<2.0 breaks our project HOT 1
- Safety scan command doesn't detect my pyproject.toml (or my env.yml) file with all its dependencies HOT 1
- Enhancement: Environment Variable to Override USER_CONFIG_DIR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from safety.