ImportError: cannot import name ‘implements‘ from ‘zope.interface‘

在这里插入图片描述

ImportError: cannot import name ‘implements’ from ‘zope.interface’

1. 问题分析

问题原因:
/home/user/.conda/envs/vectornet/lib/python3.8/site-packages/apex/interfaces.py中在使用zope.interace中使用了老表达。

2. 解决办法

原文件内容:

from zope.interface import implements
from zope.interface import Interface

class IApex(Interface):
    """ Class so that we can tell if Apex is installed from other 
    applications
    """
    pass

class ApexImplementation(object):
    """ Class so that we can tell if Apex is installed from other 
    applications
    """
    implements(IApex)

修改为:

# from zope.interface import implements
from zope.interface import implementer
from zope.interface import Interface

class IApex(Interface):
    """ Class so that we can tell if Apex is installed from other 
    applications
    """
    pass

@implementer(IApex)
class ApexImplementation(object):
    """ Class so that we can tell if Apex is installed from other 
    applications
    """
    #implements(IApex)

Error: cannot import name ‘ZopeTransactionExtension’ from ‘zope.sqlalchemy’
同样的问题
原格式

from zope.sqlalchemy import ZopeTransactionExtension
from sqlalchemy.orm import scoped_session, sessionmaker

Session = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))

修改为

from zope.sqlalchemy import register
from sqlalchemy.orm import scoped_session, sessionmaker

session_factory = sessionmaker()
Session = scoped_session(session_factory)
register(Session)

涉及文件
在这里插入图片描述
修改示例
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Moresweet猫甜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值