0

I am not very familiar with shell or bash server. I run a python script on a bash server using Keras on a classification problem.

! /bin/sh -p

python3 wrapper_DNN.py

I use a own callback functions which prints the performance at the end of each epoch. This leads to the following error:

...

File "/home/310122653/Git/DNN/Performance_callback.py", line 146, in on_epoch_end

**print** ("\u2014 train_accuracy: %f \u2014 val_f1: %f \u2014 val_precision: %f \u2014 val_recall: %f - _val_accuracy: %f"

%(_train_accuracy, _val_f1, _val_precision, _val_recall,
_val_accuracy)) UnicodeEncodeError: 'ascii' codec can't encode character '\u2014' in position 0: ordinal not in range(128)

How to tell ... ?the bash server? how to encode the ascii code (As I also run the code elsewhere I do not just want to switch off the printing)?

Directly a follow-up question, can I generally not print on a bash server (It does not have any way to view it anyway)? So, should I also use verbose mode 0 to not have any print output?

P.S. it's late here, so I might not respond immediately..

l0b0
  • 55,365
  • 30
  • 138
  • 223
Florida Man
  • 2,021
  • 3
  • 25
  • 43
  • This is a Python issue, unrelated to Bash. – l0b0 Sep 28 '18 at 20:40
  • 1
    Possible duplicate of [UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)](https://stackoverflow.com/questions/9942594/unicodeencodeerror-ascii-codec-cant-encode-character-u-xa0-in-position-20) – l0b0 Sep 28 '18 at 20:40
  • But the error only appears on the bash server...? – Florida Man Sep 28 '18 at 20:45
  • Please read the linked question and associated answers. It's a fairly common Python issue. – l0b0 Sep 28 '18 at 20:48
  • Try exporting `PYTHONIOENCODING=UTF8` in the server before starting the Python process. Or set the locale to something using UTF-8. – lenz Sep 29 '18 at 06:17

0 Answers0