'ascii' codec can't encode character...ordinal not in range(128)

21 views
Skip to first unread message

chrisbr...@gmail.com

unread,
Jun 29, 2019, 12:08:30 AM6/29/19
to mnemosyne-proj-users
Hi,

Full error message:
'ascii' codec can't encode character '\xe8' in position 14: ordinal not in range(128)
Traceback (innermost last):
File "mnemosyne/pyqt_ui/qt_worker_thread.py", line 52, in run
File "mnemosyne/pyqt_ui/import_dlg.py", line 41, in do_work
File "mnemosyne/libmnemosyne/file_formats/tsv.py", line 89, in do_import
UnicodeEncodeError: 'ascii' codec can't encode character '\xe8' in position 14: ordinal not in range(128)

The file is tab-delimited in UTF-8 exported from LibreOffice Calc.
Per instructions, UTF-8, tab, deleted string delimeter (assumed this is what you meant by "clear"). Unchecked "Save cell content as shown." Would not detect, so renamed to .tsv and it was detected. (Would be helpful to update webpage instructions to this effect.)

The character it dislikes is 'è'.

It crashes on first accented character it detects.

I have tried .txt with the same data from LibreOffice in UTF-8. Same result.

Tried exporting to US-ASCII. That imported but all accented characters were rendered as '?'.

Running macOS 10.14.5

python -V
Python 2.7.10

Was really hoping to use this program. Rest of it looks great. Hope it could be fixed soon.

Thanks,

Chris

Peter Bienstman

unread,
Jun 29, 2019, 1:14:56 AM6/29/19
to mnemosyne-...@googlegroups.com, Devin Howard, Christopher Breakspear
Hi,

I looked at the file you sent me, but it imports fine under Windows...

So, this must be some OSX specific bug. I've put Devin, our Mac developer in CC.

The relevant code is in:

https://github.com/pbienst/mnemosyne/blob/pbienst/mnemosyne/libmnemosyne/file_formats/tsv.py

f = open(filename, encoding="utf-8")

which doesn't seem to select the correct encoding on OSX...

Cheers,

Peter
> --
> You received this message because you are subscribed to the Google Groups
> "mnemosyne-proj-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mnemosyne-proj-u...@googlegroups.com.
> To post to this group, send email to mnemosyne-proj-
> us...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mnemosyne-proj-users/8edbc5b9-
> adae-4427-b8e5-ab9d33d26ec8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Devin Howard

unread,
Jun 29, 2019, 8:46:22 PM6/29/19
to Peter Bienstman, mnemosyne-...@googlegroups.com, Christopher Breakspear
This is fixed in the development version of Mnemosyne - there was a debugging statement in the TSV import code that was safely removable (https://github.com/mnemosyne-proj/mnemosyne/pull/105/files#diff-3184c33ce3586fdf619d5943bd909558)

To get the fix now, download "Mnemosyne-2.6.1-tsv-fix.dmg" from this folder https://sourceforge.net/projects/mnemosyne-proj/files/mnemosyne/mnemosyne-2.6.1/

Christopher Breakspear

unread,
Jun 29, 2019, 10:01:16 PM6/29/19
to Devin Howard, Peter Bienstman, mnemosyne-...@googlegroups.com
Perfect!  Thank you very much.

Chris
Reply all
Reply to author
Forward
0 new messages