Python 3.x 接口继承声明

Python 3.x 接口继承声明,python-3.x,inheritance,zope.interface,Python 3.x,Inheritance,Zope.interface,我试图使用一个由Github开发人员开发的旧代码。代码使用zope.interface库中的实现来声明类元素上的接口。由于库中的实现在Python 3.6中不再工作,因此我遇到以下错误: TypeError: Class advice impossible in Python3. Use the @implementer class decorator instead. 一些网站已经解释了如何用@implementer替换implements来在Python 3.6上工作,比如。但是我还没有

我试图使用一个由Github开发人员开发的旧代码。代码使用zope.interface库中的实现来声明类元素上的接口。由于库中的实现在Python 3.6中不再工作,因此我遇到以下错误:

TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead.
一些网站已经解释了如何用@implementer替换implements来在Python 3.6上工作,比如。但是我还没有找到任何例子来解释当zope.interface.implements被用作继承时如何更新代码。代码如下所示:

from zope.interface import implements
class Car(implements(Moveable)):
     def __init__(self, x, v, lane, model: IDM, lane_change: LaneChange,
             length):
...
我想更新这段代码以在Python 3.6上工作。我试过这个

@implementer(Moveable) 
class Car:
     def __init__(self, x, v, lane, model: IDM, lane_change: LaneChange,
             length):
但它不起作用。
请帮助我找出如何使上述代码在Python 3.6中运行。

要使用implementer而不是Python建议的implements,您需要导入它,而不是导入implements

from zope.interface import implementer

在您的代码中,它显示您仍在使用实现,根据提供的信息,这似乎是问题所在。希望有帮助。

以下步骤为我解决了问题

pip uninstall apex
git clone https://www.github.com/nvidia/apex
cd apex
python3 setup.py install