patarapolw / ankisync2

Creating and editing *.apkg and *.anki2 safely
MIT License
76 stars 12 forks source link

FileNotFoundError: [Errno 2] No such file or directory: '.../collection.anki21' #12

Open NicolasMICAUX opened 2 years ago

NicolasMICAUX commented 2 years ago

When opening an Apkg (deck exported from Anki2.1.15 (442df9d6), with ankisync2 0.3.4 and python 3.10.6), I get the following error :

  File "xxx.py", line 4, in <module>
    with Apkg('xxxx.apkg') as apkg:
  File "xxx/venv/lib/python3.10/site-packages/ankisync2/apkg.py", line 49, in __init__
    shutil.copy(
  File "/usr/lib/python3.10/shutil.py", line 417, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.10/shutil.py", line 254, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'xxxx/collection.anki21'
python-BaseException

Any idea why ?

Mike7154 commented 2 years ago

I get the same issue. Did you find a solution yet?

Mike7154 commented 2 years ago

Did some digging. When I open the .apkg file with winrar, I find that collection.anki21 doesn't exist. Only collection.anki2. I modified the py file "xxx/venv/lib/python3.10/site-packages/ankisync2/apkg.py" (lines 42 and 47) to look for collection.anki2 instead of collection.anki21. It loaded, but I'm not sure if everything will work the same downstream yet.

Mike7154 commented 2 years ago

I made the changes and made a pull request with the changes. It seems to work. pull request #14