Cannot get Anki 2.1 lilypond add-on to work

I installed the lilypond add-on. I tried to display a card with Anki 2.1.15 and got a bug report. So I updated to Anki 2.1.22, and now lilypond code won’t compile at all – I get the text to show as entered.

I’m on a Win 10 Desktop PC. Lilypond is in my path. Anki 2.0 version of this add-on worked just fine.

Here’s what Anki 2.1.15 said when trying to display lilypond:

Anki 2.1.15 (442df9d6) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
File “aqt\”, line 72, in handler
File “aqt\”, line 306, in _renderPreview
File “anki\”, line 120, in q
File “anki\”, line 137, in _getQA
File “anki\”, line 589, in _renderQA
File “anki\”, line 39, in runFilter
File “C:\Users\immo\AppData\Roaming\Anki2\addons21\123418104\”, line 243, in mungeFields, _imgLink(col,, _lyFromHtml(
File “C:\Users\immo\AppData\Roaming\Anki2\addons21\123418104\”, line 195, in _imgLink
err = _buildImg(col, ly, fname)
File “C:\Users\immo\AppData\Roaming\Anki2\addons21\123418104\”, line 162, in _buildImg
File “C:\Program Files\Python36\lib\encodings\”, line 19, in encode
<class ‘UnicodeEncodeError’>: ‘charmap’ codec can’t encode character ‘\u017c’ in position 366: character maps to

1 Like

Can you create a simple example that works, e.g. [lilypond]a c a b[/lilypond]?

That card is quite complex and it looks like it’s having a problem with the lyrics, specifically when it encounters ż.

I would also suggest that you make sure the card has plain text only, i.e., no formatting. Try pasting that lilypond snippet as plain text into a new card.

See this article for help on how to do that:

1 Like

I just checked: my example works as long as it has only ASCII characters. When I add an umlaut (ä) to the lyrics, the respective character is just omitted. When I add the non-Western European ż, I get the above mentioned error.

Furthermore, after receiving the error message, even the most simple lilypond code won’t compile anymore.

I also checked whether the problem lies in lilypond itself, but outside of Anki it compiles just as expected.

I think for Anki, which is primarily a language-learning tool, supporting unicode is essential in any add-on. As I already said, it used to work with Anki 2.0.