使用python 3.10 时 import paddlets报错
hxxxxh opened this issue · 4 comments
环境
os: Ubuntu 22.04.1 LTS
python: 3.10.13
paddlepaddle-gpu: 2.5.2.post117
paddlets: 1.1.0
复现
from paddlets import TSDataset
报错:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from paddlets import TSDataset
File ~/miniconda3/envs/mdm_py310/lib/python3.10/site-packages/paddlets/__init__.py:5
1 """
2 paddlets
3 """
4 from paddlets.datasets import TimeSeries, TSDataset
----> 5 from paddlets.pipeline import Pipeline
7 __version__="1.1.0"
File ~/miniconda3/envs/mdm_py310/lib/python3.10/site-packages/paddlets/pipeline/__init__.py:4
1 """
2 pipeline
3 """
----> 4 from paddlets.pipeline.pipeline import Pipeline
File ~/miniconda3/envs/mdm_py310/lib/python3.10/site-packages/paddlets/pipeline/pipeline.py:16
14 from paddlets.logger.logger import log_decorator
15 from paddlets.models.model_loader import load as paddlets_model_load
---> 16 from paddlets.utils.utils import get_tsdataset_max_len, split_dataset
18 logger = Logger(__name__)
21 class Pipeline(Trainable):
File ~/miniconda3/envs/mdm_py310/lib/python3.10/site-packages/paddlets/utils/__init__.py:8
6 from paddlets.utils.utils import get_uuid
7 from paddlets.utils.utils import check_model_fitted, check_train_valid_continuity, split_dataset
----> 8 from paddlets.utils.backtest import backtest
9 from paddlets.utils.validation import cross_validate, fit_and_score
10 from paddlets.utils.utils import plot_anoms
File ~/miniconda3/envs/mdm_py310/lib/python3.10/site-packages/paddlets/utils/backtest.py:6
4 from typing import List, Dict, Any, Callable, Optional, Tuple, Union
5 import math
----> 6 from collections import defaultdict, Iterable
8 import pandas as pd
9 import numpy as np
ImportError: cannot import name 'Iterable' from 'collections' (/home/hxx/miniconda3/envs/mdm_py310/lib/python3.10/collections/__init__.py)
经查,发现在python 3.10中已经将Iterable从collections移至collections.abc:
https://docs.python.org/3/whatsnew/3.10.html#removed
Remove deprecated aliases to Collections Abstract Base Classes from the collections module. (Contributed by Victor Stinner in bpo-37324.)
是时候进行一些兼容性修复工作了?
是的 有这个问题, 可以改成from collections.abc import Iterable
@michaelowenliu @Sunting78 Do we have a PR to address this issue? it seems no changes made to https://github.com/PaddlePaddle/PaddleTS/blob/main/paddlets/utils/backtest.py
You can check this branch which addressed this issue. thttps://github.com/PaddlePaddle/PaddleTS/blob/7b73d71848543c6f9810ea1c86da9ff07f9a5f23/paddlets/utils/backtest.py#L7
oh, it has been fixed in release_v1.0
release_v1.0 and main branches have diverged a lot.
fixing this issue in main branch will benefit our developers and users.