sobjornstad / AnkiLPCG

Addon for dae/anki for studying lyrics and poetry

Home Page:https://ankilpcg.readthedocs.io/en/latest/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error on attempt to load a poem

shenkin opened this issue · comments

I am new to Anki as well as LPCG, so perhaps I am doing something wrong.

Using Anki with some music training decks, such as the "Joe's Ear" deck, everything works properly. But when I loaded LPCG and attempted to add a simple poem I got the error shown below and in the attached screen shot.

-Peter Shenkin.

--
Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site.
Debug info:
Anki 2.1.13 (3ba55990) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.14.6
Flags: frz=True ao=True sv=1
Add-ons possibly involved: LPCG LyricsPoetry Cloze Generator

Caught exception:
File "/Users/shenkin/Library/Application Support/Anki2/addons21/2084557901/init.py", line 71, in accept
notes_generated = self._genNotes(title, tags, text, context_lines)
File "/Users/shenkin/Library/Application Support/Anki2/addons21/2084557901/init.py", line 108, in _genNotes
newNote(1, ["[First Line]"], text[0])
File "/Users/shenkin/Library/Application Support/Anki2/addons21/2084557901/init.py", line 105, in newNote
n['Line'] = line
File "anki/notes.py", line 101, in setitem
File "anki/notes.py", line 95, in _fieldOrd
<class 'KeyError'>: 'Line'

Screen Shot 2019-08-10 at 4 33 34 PM

Hi shenkin! Sorry to hear you're having trouble.

I updated my main Linux machine to the latest version of Anki (2.1.14), uninstalled LPCG, created a new profile, installed LPCG, and tried adding a poem with the settings in your screenshot, and I was not able to reproduce this behavior.

Here are some things you could try:

  • Restart your computer. This error doesn't look like a temporary issue, but it might be worth a try just in case.
  • If you have any other add-ons, try disabling all of them from Tools -> Add-ons, restarting Anki, and trying again to make sure none of them are interfering with something.
  • Upgrade to the latest version of Anki (2.1.14). I checked the changelog and didn't see anything relevant between .13 and .14, but that is one difference between our machines.
  • Does the error persist if you create a fresh profile (File -> Switch Profile) and try importing into there? If the error goes away when you create a fresh profile, please send me a copy of your collection so I can investigate further. (See here for where to find the collection.anki2 file. You can email it to anki@sorenbjornstad.com if you don't want to post it publicly here.)

If the issue still occurs in a fresh profile, I will try to reproduce this on my Mac in case it's a platform-specific thing.

After looking a bit closer at the error, trying the last point first might be the most productive. It almost looks like there's something wrong with the LPCG note type in your collection.

Hi,

First, thank you for your very rapid response.

Yes, it turned out to be the profile. When I started with a new, blank profile, it worked. (I did, of course try the other things first. :-) )

I will, of course, send you the collection.anki2 file for the profile that failed, if you still wish to see it.

But at this point, the problem is solved from my point of view, and I thank you again.

Peter S. Shenkin.

Glad you got it working!

Please do send the collection. I am guessing that you accidentally changed the LPCG note type in that profile in some way or another, but it could also be a bug on my side and if so I'd like to fix it. :-) At the very least I may be able to provide a more useful error message.

Hi,

Here is 'User 1/collection.anki2'.

'User 1' is the profile that failed.

If examining the file gives you any indication of what I might have done to create the problem, please let me know. As I mentioned, I have just started using Anki and have not at all delved into the underlying infrastructure. So I've not tried to do anything with the configuration files. Everything I've done has been from the interface, but quite possibly I did something like reboot my computer at some point without quitting Anki.

Best,
-P.

collection.anki2.zip

Sorry for the delay, GitHub seems to have not notified me of your post.

As I suspected, the Line field was missing from your LPCG note type for some reason:

field-missing

The add-on creates this note type the first time you load Anki after installing it, so without any better ideas, I'm guessing you were tweaking something unrelated and accidentally deleted the field from the note type. If you have any other insight into how the field might have gotten removed, please do let me know.

I've added an error message for people who run into this issue in the future – would this have been enough for you to fix the problem, or is there other information that I should include in it?

line-field

Typically, I would expect that if someone had removed the field from the note type (which is the case you're discussing), they would also know how to put the field back on the note type. That said, the field somehow managed to get removed from your collection without your intentionally removing it, so it's obviously possible!

I'm thinking it's better to leave the message how it is and have people read up on note types if they encounter this issue, since it's a concept they'll need to understand sooner or later anyway – explaining the whole thing would take at least a paragraph.

I will go ahead and upload a new version of LPCG and I can always edit it later if a better message or approach comes to mind.

Thanks for your feedback! Let me know if you have any other issues.