Skip to main content
 首页 » 编程设计

python之使用 musixmatch python 包装器时出错

2025年05月04日7exmyth

我一直在尝试使用 musixmatch python wrapper但是我在尝试运行 example 时遇到了一个奇怪的错误.谁能告诉我应该如何修复库?

$ 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 

请您参考如下方法:

正如@jdi in this question 所解释的那样,这是一个元类冲突:Python 不知道从哪个类派生 XMLResponseMessage。 (由于两个可能的菱形继承(钻石问题),它不可能来自两者)

有一个 Active State Recipe 可以自动解决这个问题(无冲突模块):http://code.activestate.com/recipes/204197-solving-the-metaclass-conflict/ .缺点是必须深入lib代码修改才能解决冲突。

据我所见,这个库是为开发者量身定制的,只能在他的环境中运行:python 2.7(元类冲突)和 python 3.3(无法安装 egg 模块)都无法安装并测试模块。我建议您 fork 代码,并根据您的需要进行调整。