2

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
4

1 に答える 1

1

この質問で@jdi が説明したように、これはメタクラスの競合です。Python は、どのクラスから XMLResponseMessage を派生させるかを認識していません。(2つの可能なダイヤモンド継承のため、両方からではありません)

この問題を自動的に解決する Active State Recipe があります (noconflict モジュール): http://code.activestate.com/recipes/204197-solving-the-metaclass-conflict/。欠点は、lib コードに飛び込んで変更し、競合を解決する必要があることです。

私が見たところ、このライブラリは開発者の目的に合わせて調整されており、彼の環境でのみ実行できます。python 2.7 (メタクラスの衝突) も python 3.3 (egg モジュールをインストールできない) もインストールしてテストできません。モジュール。コードをフォークして、ニーズに合わせることをお勧めします。

于 2013-06-24T09:07:25.060 に答える