天天看点

python怎么用matplotlib_python-无法在我的程序中使用matplotlib函数

我正在Windows 10(conda版本4.3.8)中运行Anaconda安装

这是我试图在python命令行中运行的代码:

import matplotlib.pyplot as plt

x = [1,2,3,4]

y = [5,6,7,8]

plt.figure(1)

plt.plot(x,y)

最后一行引发以下错误:

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\font_manager.py:971: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1.

if is_string_like(family):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\font_manager.py:697: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1.

if is_string_like(family):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\text.py:218: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1.

elif is_string_like(fontproperties):

Traceback (most recent call last):

File "", line 1, in

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 3307, in plot

ax = gca()

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 950, in gca

return gcf().gca(**kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1368, in gca

return self.add_subplot(1, 1, 1, **kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1020, in add_subplot

a = subplot_class_factory(projection_class)(self, *args, **kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_subplots.py", line 73, in __init__

self._axes_class.__init__(self, fig, self.figbox, **kwargs)

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 529, in __init__

self._init_axis()

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 622, in _init_axis

self.xaxis = maxis.XAxis(self)

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py", line 676, in __init__

self.cla()

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py", line 760, in cla

self.reset_ticks()

File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py", line 771, in reset_ticks

cbook.popall(self.majorTicks)

AttributeError: module 'matplotlib.cbook' has no attribute 'popall'

我在根环境中运行它这也是conda列表输出的一部分

python怎么用matplotlib_python-无法在我的程序中使用matplotlib函数

根目录中是否存在多个版本的matplotlib导致此问题?我该如何解决?