每当导入matplotlib时都会出现属性错误



每次我将matplotlib导入python程序时,我都会收到这个错误(这里的程序只有一行"import matplotlib.pyplot as plt"(:

Traceback (most recent call last):   
File "string.py", line 1, in <module>  
import matplotlib.pyplot as plt   
File "D:Other programsPython38libsite-packagesmatplotlib__init__.py", line 94,
in <module>      
import logging   
File "D:Other programsPython38liblogging__init__.py", line 28, in <module>    
from string import Template   
File "D:programspythonstring.py", line 1, in <module>    
import matplotlib.pyplot as plt   
File "D:Other programsPython38libsite-packagesmatplotlibpyplot.py", line 36, in <module>    
import matplotlib.colorbar   
File "D:Other programsPython38libsite-packagesmatplotlibcolorbar.py", line 40, in <module>    
import matplotlib.artist as martist   
File "D:Other programsPython38libsite-packagesmatplotlibartist.py", line 17, in <module>    
_log = logging.getLogger(__name__)   
AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely
due to a circular import)

我在任何地方都找不到日志.py。这是matplotlib最新版本中的某种错误吗?

您的脚本D:programspythonstring.py,其中尝试import matplotlib.pyplot as plt被命名为string.py,它会干扰标准库中的string模块。重命名该文件。

最新更新