Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Everytime I import matplotlib into my python programs I get this error (here the program is just one line "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)

I cannot find any logging.py anywhere. Is this some sort of bug in the lates version of matplotlib?

question from:https://stackoverflow.com/questions/65642390/attribute-error-whenever-i-import-matplotlib

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
138 views
Welcome To Ask or Share your Answers For Others

1 Answer

your script D:programspythonstring.py, where you try to import matplotlib.pyplot as plt is named string.py and it interferes with string module from standard library. Rename that file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...