【报错】AttributeError: module ‘transformers.utils.logging‘ has no attribute ‘getLogger‘

这种类型的报错,多半是因为import了多个重名的包,导致运行的时候,后面导入的包,把前面正确的包覆盖了

比方说:

import logging
from transformers.trainer import *

logger = logging.getLogger(__name__)

由于transformers.trainer下也有一个logging,所以覆盖了第一行的import。


from transformers.trainer import *这种写法是非常不好的,把大包里的所有包都倒入,经常会出现把其他同名包覆盖掉的现象。建议用什么,就导入什么,不要用*

你可能感兴趣的:(各类报错,python,transformer)