FreeLanguageTools / vocabsieve

Simple sentence mining tool for language learning
GNU General Public License v3.0
394 stars 30 forks source link

Error in Anki 'No such file or directory' when trying to add an image #138

Closed Guym142 closed 8 months ago

Guym142 commented 9 months ago

Describe the bug When attaching an image, the resulting card in Anki shows an error in the 'Image' field: [Errno 2] No such file or directory: 'C:/Users/user/AppData/Local/FreeLanguageTools/VocabSieve\\images\\1708805656888.jpg'

To Reproduce Steps to reproduce the behavior:

  1. Copy an image to clipboard by using right click > copy image (in chrome browser)
  2. Add a sentence by copying text
  3. Choose a word by double clicking
  4. Click Add note [Ctrl+S]
  5. Click View last note

Expected behavior The image should appear in the card that was created

Screenshots image image

Logs

2024-02-24 22:14:11.198 | DEBUG    | vocabsieve.main:initSources:130 - Initializing sources
2024-02-24 22:14:11.199 | DEBUG    | vocabsieve.main:initSources:134 - Source Group 1: ['Wiktionary (English)'] has been created.
2024-02-24 22:14:11.199 | DEBUG    | vocabsieve.main:initSources:146 - Source Group 2 is disabled, emptying source widget.
2024-02-24 22:14:11.199 | DEBUG    | vocabsieve.main:initSources:153 - Audio source group: ['Forvo'] has been created
2024-02-24 22:14:11.199 | DEBUG    | vocabsieve.main:initTimers:968 - Initializing timers
2024-02-24 22:14:11.207 | DEBUG    | vocabsieve.main:getKnownDataOnThread:381 - Some data sources aren't available, not getting known data now
2024-02-24 22:14:24.143 | INFO     | vocabsieve.main:lookupSelected:645 - Triggered lookup on dessin
2024-02-24 22:14:24.561 | INFO     | vocabsieve.sources.ForvoAudioSource:_lookup:168 - Forvo lookup dessin
2024-02-24 22:14:26.848 | DEBUG    | vocabsieve.main:findDuplicates:660 - Trying to obtain fields for note type "vocabsieve-notes"
2024-02-24 22:14:26.879 | DEBUG    | vocabsieve.main:findDuplicates:663 - Fields for note type "vocabsieve-notes": ['Sentence', 'Word', 'Definition', 'Definition#2', 'Image', 'Pronunciation']
2024-02-24 22:14:26.880 | INFO     | vocabsieve.main:findDuplicates:673 - First field is sentence field, trying to find a note with field "Sentence" having value "Mon dessin ne représentait pas un chapeau"
2024-02-24 22:14:26.977 | DEBUG    | vocabsieve.main:findDuplicates:686 - Did not find Anki note
2024-02-24 22:14:26.977 | INFO     | vocabsieve.main:createNote:871 - Creating note
2024-02-24 22:14:26.979 | DEBUG    | vocabsieve.main:createNote:885 - Prepared Anki note json{
    "deckName": "# VocabSieve",
    "modelName": "vocabsieve-notes",
    "fields": {
        "Word": "dessin",
        "Sentence": "Mon dessin ne représentait pas un chapeau",
        "Definition": "<em>Noun</em> \n<br>1. drawing \n<br>2. design (pattern)",
        "Definition#2": ""
    },
    "tags": [
        "vocabsieve"
    ],
    "audio": [
        {
            "fields": [
                "Pronunciation"
            ],
            "url": "https://audio00.forvo.com/audios/mp3/4/l/4l_9505057_49_627757.mp3",
            "filename": "4l_9505057_49_627757.mp3"
        }
    ],
    "picture": [
        {
            "path": "C:/Users/user/AppData/Local/FreeLanguageTools/VocabSieve\\images\\1708805656888.jpg",
            "filename": "C:/Users/user/AppData/Local/FreeLanguageTools/VocabSieve\\images\\1708805656888.jpg",
            "fields": [
                "Image"
            ]
        }
    ]
}
2024-02-24 22:14:27.154 | INFO     | vocabsieve.main:createNote:902 - Note added to Anki

Desktop:

1over137 commented 9 months ago

but does the file actually exist?

Guym142 commented 9 months ago

but does the file actually exist?

No, the file doesn't exist in this path

1over137 commented 9 months ago

Can't reproduce this. It works fine for me even on Windows. I was able to add several cards. Does this occur on every image you try to paste, or only some? What if you reset your settings?

1over137 commented 8 months ago

does this still occur?

Guym142 commented 8 months ago

Yes, it still happens even after reinstalling

1over137 commented 8 months ago

You sure you didn't skip something? There should really be a line in the log like this: Received image, saving to disk as ....

1over137 commented 8 months ago

Ah, I think I know what went wrong. Can you press Help -> Open data folder, and check if there is a folder name "images"? If it is not present, create it. This should probably fix it. I think I accidentally removed the code to create it

Guym142 commented 8 months ago

Solved in version 0.12.0