-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when redirecting output on Windows #16
Comments
FYI, I tested this both from CMD and from bash (installed from posix conda meta-package), and I get the same error in either. |
hello, I don't use windows, so I'm not sure what this means, does this also happens with other python scripts ? |
Setting PYTHONIOENCODING=utf-8 got rid of the crash, but the resulting
output file has many escape codes in it. I see you have coloarama as a
dependency, so I'm guessing you're trying to color the output. However,
interestingly, I don't see any colors when I output the results to the
console.
…On Thu, Dec 16, 2021 at 9:33 AM Renan Valieris ***@***.***> wrote:
hello,
I don't use windows, so I'm not sure what this means, does this also
happens with other python scripts ?
does setting set PYTHONIOENCODING=utf-8 helps ?
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP6TT7ZQ6OHUNJLCL7EX5JDURH2CHANCNFSM5KEETZCA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
currently colorama is only being used to dim the package versions, like a dark gray-ish color, I don't know if cmd supports this. there are 2 issues here I think:
try this:
|
Sorry for the delayed reply; it looks like I missed this message when you
originally sent it. Regardless, it appears that adding the colorama.init()
call and setting PYTHONIOENCODING=utf-8 has fixed both issues.
…--David
On Fri, Dec 17, 2021 at 6:57 AM Renan Valieris ***@***.***> wrote:
currently colorama is only being used to dim the package versions, like a
dark gray-ish color, I don't know if cmd supports this.
there are 2 issues here I think:
1. there is a colorama.init() that detects windows and change the
escape codes, the script is not calling this currently, so the escape codes
are probably wrong.
2. the deptree output uses box drawing characters
<https://en.wikipedia.org/wiki/Box-drawing_character>, without knowing
the encoding, these characters might show up as gibberish in the file
try this:
- add import colorama; colorama.init() to the top of the script
- try setting PYTHONIOENCODING=utf-8 or PYTHONIOENCODING=utf-16 and
check the file results
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP6TT72LOMLVYCJ4HRT5T3TURMQT7ANCNFSM5KEETZCA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
More details can be found at tartley/colorama#319 cp1252.py is not showing the exact characters, but once I added
Instead of setting sys.stdout.reconfigure(encoding='utf-8') to the top of conda_tree.py |
When I try to redirect the output of "conda-tree deptree" to a file or pipe through more or tee on Windows 10, I get the following error:
Traceback (most recent call last):
File "C:\Users\manow\anaconda3\Scripts\conda-tree-script.py", line 9, in
sys.exit(main())
File "C:\Users\manow\anaconda3\lib\site-packages\conda_tree.py", line 345, in main
print(''.join(complete_tree), end='')
File "C:\Users\manow\anaconda3\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 21-22: character maps to
However, if I just let the output go to the console, I have no problem.
The text was updated successfully, but these errors were encountered: