2013-06-20 34 views
2

我一直在嘗試使用musixmatch python wrapper,但在嘗試運行example時遇到了一個奇怪的錯誤。任何人都可以告訴我應該怎樣修理這個圖書館?使用musixmatch python包裝時出錯

$ python 
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
[GCC 4.4.5] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import musixmatch.ws 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "musixmatch/ws.py", line 14, in <module> 
    import musixmatch.api 
    File "musixmatch/api.py", line 167, in <module> 
    class XMLResponseMessage(ResponseMessage, etree.ElementTree): 
TypeError: Error when calling the metaclass bases 
    metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases 

回答

1

正如@jdi in this question解釋說,這是一個元類confict:Python不知道從哪個類派生自XMLResponseMessage。 (它不能來自兩個可能的鑽石繼承)

有一個活動狀態配方自動解決這個問題(noconflict模塊):http://code.activestate.com/recipes/204197-solving-the-metaclass-conflict/。缺點是你必須深入到lib代碼並修改它來解決衝突。

從我看到的,這個庫是爲開發目的而量身定做的,只能在他的環境下運行:python 2.7(metaclass clash)和python 3.3(無法安裝egg模塊)都能夠安裝並測試模塊。我會建議你分叉代碼,並根據你的需要進行調整。