ttempe / chinese-support-addon

Addon for Anki2 that makes easier to input Chinese, in the spirit of batterseapower’s pinyin-toolkit for Anki1
https://github.com/ttempe/chinese-support-addon/wiki
47 stars 19 forks source link

Interference with other add-ons #58

Open ospalh opened 9 years ago

ospalh commented 9 years ago

The “Quick-and-dirty trick” to fix #7 is too dirty for my taste.

For my add-on i came up with what i think is reasonably clever code to use a site packages when it is installed and to ignore that when it’s not there, basically

try:
    from pydub.silence import detect_nonsilent
    # Look for a reasonable new pydub
except ImportError:
    processor = None
else:
    from .audio_processor import AudioProcessor
    processor = AudioProcessor()

And later just use if processor to either use this code or not.

The problem is that the import will never work, because your add-on removed the directory where the site packages is from the search path.

I guess my branch is not really a solution. That would be back to square one, or issue #7.

Afaik the problem is different versions of several libraries your add-on brings along. (Although i can’t find cjklib any more.) Maybe it works when you leave the paths alone and use relative imports like from .python-2.7-modules import md5 instead of plain import md5. Note the dot before the pytho-2.7-modules. (I have not tried this. Just a general idea.)