djsudduth / keep-it-markdown

Convert Google Keep notes dynamically to markdown for Obsidian, Logseq, Joplin and Notion using the unofficial Keep API. Also, import simple markdown notes back into Google Keep.
Apache License 2.0
493 stars 32 forks source link

Error when running kim.py #46

Closed tedblizzard100 closed 2 years ago

tedblizzard100 commented 2 years ago

I am getting this error: "local variable 'md_file' referenced before assignment" Is there any workaround - Please? Thank you

djsudduth commented 2 years ago

Do you get this error every time you run kim.py? If so, can you try running kim.py with a search term that isolates down to 1 or 2 notes? Does that fail as well? Couple of thoughts come to mind:

  1. Are you running the latest version of kim v-0.4.3?
  2. Is your settings.cfg file correct for the output? Try setting it to default values by overwriting it with this [SETTINGS] google_userid = \<yourid> output_path = mdfiles media_path = media
  3. Can you narrow down output to find a specific note causing the problem (unless it is happening all the time)?

If these don't work then try downloading kim again in another directory to see if that works.

tedblizzard100 commented 2 years ago

Thank you @djsudduth I really appreciate your help. I updated to 0.4.3 and checked the settings as you spesified. I am getting a new error::

Enter a keyword search, label search or '--all' to convert Keep notes to md or '--x' to exit: ToObsidian Error in keep_query_convert() Conversion to markdown error - UnboundLocalError("local variable 'md_file' referenced before assignment") Could not excute KIM

Is this help identify the issue? What else can I do? Thank you so much for your help.

djsudduth commented 2 years ago

Sure @tedblizzard100 - after debugging this a bit, I see the error appears if your output_path or media_path in the config file has one of these issues:

  1. Either are pointing to a read-only directory
  2. The pathnames are incorrect for the path you want
  3. KIM cannot create those directories for output or media
  4. The media path is not relative
  5. The directories are full
  6. Invalid characters are used for the path names (or invalid slashes - remember, you must use forward slashes for directories - even on Widows)

See if you can just use the config defaults (mdfiles under the kim install directory and media under the mdfiles directory) and make sure they are writable. (so your directory layout should be ../(kim install directory)/mdfiles/media )

Looks like I need to add some file/directory error handling to report the error better. I will add that.

djsudduth commented 2 years ago

@tedblizzard100 I also just want to verify - does this error occur if converting a single simple note that has a title, some text and no attached media (picture or drawing)?? (Just find a note that is unique for one word or just create one)

tedblizzard100 commented 2 years ago

Thank you so much @djsudduth for your help. I am sure you are correct. It is a problem with my path. It is not even accessing the Google Keep data at the point because the error is instant. This is what I have in the config file does any of this look wrong (Note I am on windows): [SETTINGS] google_userid = <> output_path = "C:\Users\tedbl\Google Drive\Second Brain\VBrainCV2\GoogleKeepNotes" media_path = "media"

djsudduth commented 2 years ago

Ok - I see the issue. Do this:

tedblizzard100 commented 2 years ago

@djsudduth Thank you again for all your help.

  1. the <> is where my email address is. I just put this <> for reference. It seems to log me in fine with my email address.
  2. I changed the \ to /
  3. I used single quotes and verified the path
  4. Media_path tried with and without quotes both produce the same error.
  5. I am not using any line feeds in the path names

This is my config: [SETTINGS] google_userid = myemailaddress@gmail.com output_path = 'C:/Users/tedbl/Google Drive/Second Brain/VBrainCV2/GoogleKeepNotes' media_path = 'media'

But I am still getting the same error: Enter a keyword search, label search or '--all' to convert Keep notes to md or '--x' to exit: ToObsidian Error in keep_query_convert() Conversion to markdown error - UnboundLocalError("local variable 'md_file' referenced before assignment") Could not excute KIM

djsudduth commented 2 years ago

Tey removing the quotes on 'media'

tedblizzard100 commented 2 years ago

Yes, Thank you. both ways with and without quotes as indicated in number 4 above. Same error.

djsudduth commented 2 years ago

Ok, so you need to try the simple test - just use the KIM install directory and set the settings.cfg to the defaults of mdfiles and media. Make sure that works before altering any paths - then, evolve it from there. Meanwhile, I'll create a directory the same as yours and try to see where the issue is.

djsudduth commented 2 years ago

Ok, I did a test - remove all quotes from any of paths. I had the same errors you had any time I added single or double quotes. Once I removed them, it worked.

tedblizzard100 commented 2 years ago

YES! It worked perfectly. Thank you so much @djsudduth for all your help.

djsudduth commented 2 years ago

Fantastic!!! Hope you enjoy it. The next version will be out in a couple of months. Adding bulleted Logseq markdown and import from Google Takeout (some of the features). Let me know if there are features you'd like to see.