本文主要是介绍Python报错“ImportError:most likely due to a circular import“记录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Traceback (most recent call last):File "/Users/pengchen/workspace/pythonProject1/常用内建模块/datetime.py", line 1, in <module>from datetime import datetime, timezone, timedeltaFile "/Users/pengchen/workspace/pythonProject1/常用内建模块/datetime.py", line 1, in <module>from datetime import datetime, timezone, timedelta
ImportError: cannot import name 'datetime' from partially initialized module 'datetime' (most likely due to a circular import) (/Users/pengchen/workspace/pythonProject1/常用内建模块/datetime.py)
也是奇葩,datetime时python常用内建模块,然后我为了学习,也就将其命名为datetime,所以造成死循环导入,而没有将真正的内置模块导入,这种错误,只需要将文件名改成不和包重名即可。
这篇关于Python报错“ImportError:most likely due to a circular import“记录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!