Windows+Jupyter环境下'matplotlib.axes._subplots'模块缺失问题求助
问题:导入timeseries_generator时触发ModuleNotFoundError(找不到matplotlib.axes._subplots)
环境信息
- Windows 11 Home(版本10.0.22631,Dell G15 5520 x64)
- Python 3.12,pip与Python已配置到系统PATH,基础命令运行正常
- 使用Jupyter Notebook开发
依赖包情况
项目使用的包及安装方式:
from timeseries_generator import LinearTrend, Generator, WhiteNoise, RandomFeatureFactor # 安装方式:pip install git+https://github.com/Nike-Inc/timeseries-generator.git 或 pip install jupyter git+https://github.com/Nike-Inc/timeseries-generator.git import pandas as pd import matplotlib # 因报错单独安装过 import keras # 后续用于机器学习
报错详情
运行示例代码时出现如下错误:
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[3], line 1 ----> 1 from timeseries_generator import LinearTrend, Generator, WhiteNoise, RandomFeatureFactor 2 import pandas as pd 3 import matplotlib File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\timeseries_generator\__init__.py:1 ----> 1 from .base_factor import BaseFactor 2 from .errors import * 3 from .generator import Generator File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\timeseries_generator\base_factor.py:5 2 from typing import List, Dict, Optional, Union, Tuple 4 from matplotlib.figure import Figure ----> 5 from matplotlib.axes._subplots import SubplotBase 6 from matplotlib.pyplot import subplots 7 from pandas import DataFrame, date_range, DatetimeIndex ModuleNotFoundError: No module named 'matplotlib.axes._subplots'
已尝试的无效解决方法
- 仅保留单个Python版本
- 更新所有已安装的依赖包
- 单独重新安装matplotlib(安装时提示依赖已满足:
Requirement already satisfied: types-python-dateutil>=2.8.10 in c:PATH-To-Python\python312\lib\site-packages (from arrow>=0.15.0->isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (2.9.0.20240316)
- 在Jupyter单元格内直接执行安装命令
运行的Jupyter代码
from timeseries_generator import LinearTrend, Generator, WhiteNoise, RandomFeatureFactor import pandas as pd import matplotlib import keras # 构建线性趋势 lt = LinearTrend(coef=2.0, offset=1., col_name="my_linear_trend") g = Generator(factors={lt}, features=None, date_range=pd.date_range(start="01-01-2020", end="01-20-2020")) g.generate() g.plot() # 为生成器添加白噪声 wn = WhiteNoise(stdev_factor=0.05) g.update_factor(wn) g.generate() g.plot()
需求
需要生成用于机器学习的合成时序数据图表,请求可行的解决方案。
内容的提问来源于stack exchange,提问作者aibe0815
相关产品推荐
相关产品推荐

