[BUG] Command python.exe -m rich.emoji
throws an error when the output is redirected to a file
#3766
Replies: 3 comments
-
We found the following entries in the FAQ which you may find helpful:
Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review. This is an automated reply, generated by FAQtory |
Beta Was this translation helpful? Give feedback.
-
It appears as though the encoding defaults to cp1252 when piping, which can't handle the emojis. You could try setting PYTHONIOENCODING env var to "utf-8". |
Beta Was this translation helpful? Give feedback.
-
Does encoding change when output is piped? Without piping, the command works and i can see the emojis on terminal. Why should redirecting the output from console to a file cause python encoding to change? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
On Windows PowerShell or CMD,
python.exe -m rich.emoji | Out-File -encoding unicode ".\richEmoji"
causes errorI am trying to create a file having list of emojis and the text to invoke them. For this i tried redirecting the output of recommended
python.exe -m rich.emoji
to a file with a pipeline. But this causes the errorUnicodeEncodeError: 'charmap' codec can't encode character '\U0001f44d' in position 0: character maps to <undefined>
Here is the output:
Removing the pipeline results in the emojis being returned normally.
Platform
Click to expand
What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
Windows 11 Enterprise with PoweShell terminal
I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.
If you're using Rich in a terminal:
Beta Was this translation helpful? Give feedback.
All reactions