Skip to content

修复 matplotlib 3.9 兼容性等 issues - #194

Open
yinlb3 wants to merge 1 commit into
nmcdev:masterfrom
yinlb3:master
Open

yinlb3 wants to merge 1 commit into
nmcdev:masterfrom
yinlb3:master

Conversation

@yinlb3

@yinlb3 yinlb3 commented Sep 17, 2026

Copy link
Copy Markdown

问题

(1)在 matplotlib >= 3.9 环境下,调用 meb.def_cmap_clevs(...)(内部调用 cm.get_cmap)会报错 AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap',因为 matplotlib.cm.get_cmap 在 matplotlib 3.9 中已被移除,涉及 4 个文件共 19 处;
(2)另外 pip install -e . 会失败:setup.py 第 11 行 version = __import__(name).__version__ 在构建时导入 meteva 包本身,触发 meteva/__init__.py → from . import method → from . import vector 的循环导入;
(3)排查中还发现目录大小写问题,method下目录名 Vector 与代码 from . import vector 不一致会报错。

修改内容

(1)4 个文件共 19 处 cm.get_cmap 替换为 plt.get_cmap(matplotlib >= 3.0 均可用,兼容旧版本);
(2)setup.py 改用正则从 meteva/__init__.py 读取 __version__,避免构建时导入包本身,添加 pyproject.toml 声明构建系统;
(3)method下文件夹Vector改为vector。

测试

matplotlib 3.9 环境下原先报错的绘图流程运行正常;pip install -e . 可正常完成。

- Replace cm.get_cmap with plt.get_cmap for matplotlib 3.9 compatibility
- Read version via regex in setup.py to fix installation bug, add pyproject.toml
- Rename Vector directory to vector to fix import error in method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant