Fixing the "sqlalchemy.exceptions / cjklib" error in Pinyin Toolkit for Anki
I upgraded to Linux Mint 13 yesterday, and when I got round to reinstalling Anki and the Pinyin Toolkit, I got this error:
Traceback (most recent call last): File “/usr/share/anki/ankiqt/ui/main.py”, line 2679, in loadPlugins import(nopy) File “/home/hugh/.anki/plugins/Pinyin Toolkit.py”, line 29, in import pinyin.anki.main as main File “/home/hugh/.anki/plugins/pinyin/anki/main.py”, line 11, in import pinyin.db.builder File “/home/hugh/.anki/plugins/pinyin/db/builder.py”, line 3, in import cjklib.build File “/home/hugh/.anki/plugins/pinyin/../pinyin/vendor/cjklib/cjklib/build/init.py”, line 62, in from sqlalchemy.exceptions import OperationalError ImportError: No module named exceptionschinese forums comics project
A bit of Googling suggests that the problem is due to the module cjklib being badly out of date, and making incorrect calls to another thing called sqlalchemy which has been updated in the new Linux Mint. At least that’s my understanding. In any case, Pinyin Toolkit doesn’t work anymore, and it’s a pain in the arse.
I’ve spent several hours faffing around with this trying various things, and finally have a solution. Hopefully this little write-up will save someone else from wasting their afternoon!
The fix is fairly simple, but there’s quite a lot of steps involved.
You just need to change two files to fix the problem. I’ve uploaded the fixed versions:
Download and extract that archive, go into the folder, and copy the two files in there called builder.py and init.py:
Now navigate to this folder from your home directory (you’ll need to press ctrl + h to show hidden files):
.anki/plugins/pinyin/vendor/cjklib/cjklib/build
Just to be clear, there are two folders called cjklib, one within the other. Now just paste the two files you downloaded into that directory, confirming that you want to overwrite the originals. Next time you start Anki, the problem should have been solved!
If you prefer, you can access the fixed files online and copy and paste the contents from them:
All I’ve done is applied this patch, then copied and uploaded the files it modified. You could of course do that yourself, I just thought it would be easier to download and copy the files directly.