如何让 matplotlib 实际更新到最新版本?

How do I get matplotlib to actually update to the latest version?

我正在尝试通过设置 labelcolor 参数来更改条形图图例中的字体颜色,看起来我需要 Matplotlib 3.3 或更高版本才能这样做(目前我是当我尝试时得到 TypeError: __init__() got an unexpected keyword argument 'labelcolor')。我目前安装了 3.2.2。

我在我的基本环境和自定义环境中都尝试了 运行 conda install -c conda-forge matplotlib,它只是再次“更新”到 3.2.2。我宁愿避免尝试 pip 安装,这样我就不会冒险搞砸其他软件包。

提前致谢。

命令

conda install -c conda-forge matplotlib

翻译成命令式

With the conda-forge channel prioritized, ensure that some version of the package matplotlib is installed in the current environment.

相比之下,根据 OP,我们需要命令式语句

Ensure that at least version 3.3 of the matplotlib package is installed in the current environment.

转换为命令

conda install matplotlib[version='>=3.3']

这不保证 Conda 可以满足此命令(例如,它可能与以前的规范冲突),只是这是直译。

频道规范

请注意,包含 -c conda-forge 将优先考虑该通道,但并未明确指定 Conda 必须使用该通道来获取包。这是因为 Conda 还会考虑 channel_priority 配置值,并且会根据设置的是 'strict' 还是 'flexible' 表现不同。

但是,Conda 的 MatchSpec 具有足够的表现力来明确要求特定包来自给定渠道。例如,要求至少从 Conda Forge 安装 3.3 版,将采用

形式
conda install conda-forge::matplotlib[version='>=3.3']