我正在为Python 3.7.3设置vs代码,当我尝试将matplotlib.pyplot导入为plt时,出现错误了吗?
我已经尝试卸载并重新安装matplotlib,但是它不起作用。
import os
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 100) # Create a list of evenly-spaced numbers over the range
plt.plot(x, np.sin(x)) # Plot the sine of each x point
plt.show() # Display the plot
Traceback (most recent call last):
File "c:/Users/sagittarius1507/Desktop/Python/string.py", line 2, in <module>
import matplotlib.pyplot as plt
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\__init__.py", line 127, in <module>
import logging
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 28, in <module>
from string import Template
File "c:\Users\sagittarius1507\Desktop\Python\string.py", line 2, in <module>
import matplotlib.pyplot as plt
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\pyplot.py", line 32, in <module>
import matplotlib.colorbar
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\colorbar.py", line 25, in <module>
import numpy as np
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\__init__.py", line 187, in <module>
from .testing import Tester
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\testing\__init__.py", line 10, in <module>
from unittest import TestCase
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\unittest\__init__.py", line 59, in <module>
from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
File "C:\Users\sagittarius1507\AppData\Local\Programs\Python\Python37\lib\unittest\case.py", line 278, in <module>
class _CapturingHandler(logging.Handler):
AttributeError: module 'logging' has no attribute 'Handler'