AttributeError:'module' xxx.py has no attribute '__path__'

遇到一個局坑爹的bug,實際很簡單,但卻很難發現到底是哪裏出了問題——

Error while finding module specification for 'convert_albert_original_tf_checkpoint_to_pytorch.py' (AttributeError: module 'convert_albert_original_tf_checkpoint_to_pytorch' has no attribute '__path__')

即“AttributeError:'module' xxx.py has no attribute '__path__' ”,其實問題很簡單,你去看看你的命令是不是有這個問題:

$ python -m xxx.py

如上面的命令所示,Python -m指的是把這個.py文件當做模塊運行,但如果你一不小心加了.py這個後綴,就會出現這個錯誤。其實你要麼把"-m"刪除,要麼刪除".py"後綴,問題就迎刃而解了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章