python-3.6 'ascii' codec can't encode character '\xed'
pavelrevak opened this issue · 2 comments
pavelrevak commented
from your example:
In [1]: from ares_util.ares import call_ares
In [2]: call_ares(42)
Out[2]: False
In [3]: call_ares('68407700')
Out[3]: ---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-3-d55edeea105c> in <module>()
----> 1 call_ares('68407700')
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/displayhook.py in __call__(self, result)
259 self.fill_exec_result(result)
260 if format_dict:
--> 261 self.write_format_data(format_dict, md_dict)
262 self.log_output(format_dict)
263 self.finish_displayhook()
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/displayhook.py in write_format_data(self, format_dict, md_dict)
188 result_repr = '\n' + result_repr
189
--> 190 print(result_repr)
191
192 def update_user_ns(self, result):
UnicodeEncodeError: 'ascii' codec can't encode character '\xed' in position 75: ordinal not in range(128
illagrenan commented
It looks[1] like a problem with IPython and/or your (output) locale settings.
My suggestions:
- Try if
call_ares
function works for you:
res = call_ares('68407700')
assert 'legal' in res
assert 'address' in res
- Try to upgrade ipython:
pip install --upgrade ipython
- Try to print (in ipython and standard Python repl) text with accented characters:
print('Příliš žluťoučký kůň úpěl ďábelské ódy.')
pavelrevak commented
OK it was caused by wrong locales in terminal.
Thanks