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 Interfaceclass IApex(Interface):""" Class so that we can tell if Apex is installed from other applications"""passclass 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 Interfaceclass 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, sessionmakerSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
修改为
from zope.sqlalchemy import register
from sqlalchemy.orm import scoped_session, sessionmakersession_factory = sessionmaker()
Session = scoped_session(session_factory)
register(Session)
涉及文件
修改示例