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,  timedelta
  File "/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)

Python报错“ImportError:most likely due to a circular import“记录_第1张图片
在这里插入图片描述
也是奇葩,datetime时python常用内建模块,然后我为了学习,也就将其命名为datetime,所以造成死循环导入,而没有将真正的内置模块导入,这种错误,只需要将文件名改成不和包重名即可。
Python报错“ImportError:most likely due to a circular import“记录_第2张图片

你可能感兴趣的:(编程语言,python)