首页 > 解决方案 > 可变关键字参数不能有默认值

问题描述

从昨天开始

import matplotlib.pyplot as plt 

给我这个 ValueError “可变关键字参数不能有默认值”。

错误下方:

ValueError                                Traceback (most recent call last)
<ipython-input-1-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\pyplot.py in <module>
     30 from cycler import cycler
     31 import matplotlib
---> 32 import matplotlib.colorbar
     33 import matplotlib.image
     34 from matplotlib import rcsetup, style

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\colorbar.py in <module>
     38 
     39 import matplotlib as mpl
---> 40 import matplotlib.artist as martist
     41 import matplotlib.cbook as cbook
     42 import matplotlib.collections as collections

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\artist.py in <module>
     58 
     59 
---> 60 class Artist:
     61     """
     62     Abstract base class for objects that render into a FigureCanvas.

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\artist.py in Artist()
    899 
    900     @cbook._delete_parameter("3.3", "args")
--> 901     @cbook._delete_parameter("3.3", "kwargs")
    902     def draw(self, renderer, *args, **kwargs):
    903         """

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\cbook\deprecation.py in _delete_parameter(since, name, func)
    343         param.replace(default=_deprecated_parameter) if param.name == name
    344         else param
--> 345         for param in signature.parameters.values()])
    346 
    347     @functools.wraps(func)

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\cbook\deprecation.py in <listcomp>(.0)
    343         param.replace(default=_deprecated_parameter) if param.name == name
    344         else param
--> 345         for param in signature.parameters.values()])
    346 
    347     @functools.wraps(func)

~\Anaconda3\lib\inspect.py in replace(self, name, kind, annotation, default)
   2547             default = self._default
   2548 
-> 2549         return type(self)(name, kind, default=default, annotation=annotation)
   2550 
   2551     def __str__(self):

~\Anaconda3\lib\inspect.py in __init__(self, name, kind, default, annotation)
   2474                 msg = '{} parameters cannot have default values'
   2475                 msg = msg.format(_get_paramkind_descr(self._kind))
-> 2476                 raise ValueError(msg)
   2477         self._default = default
   2478         self._annotation = annotation

ValueError: variadic keyword parameters cannot have default values

我试图卸载 matplotlib 并重新安装它并安装不同的版本,但似乎没有任何效果

有人有其他想法吗?谢谢你

标签: pythonmatplotlibanaconda

解决方案


推荐阅读