facebookresearch / Kats

Kats, a kit to analyze time series data, a lightweight, easy-to-use, generalizable, and extendable framework to perform time series analysis, from understanding the key statistics and characteristics, detecting change points and anomalies, to forecasting future trends.
MIT License
4.88k stars 534 forks source link

Kats throw an error module 'packaging.version' has no attribute 'LegacyVersion' #282

Closed KansaiUser closed 1 year ago

KansaiUser commented 1 year ago

This is the first time using Kats

I tried to use it with python 3.6 but it threw an error

future feature annotations is not defined

so instead I used python 3.9 and now when I do

from kats.detectors.outlier import OutlierDetector
outlier_detector = OutlierDetector(ts_day, "additive")

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[19], line 1
----> 1 from kats.detectors.outlier import OutlierDetector
      3 outlier_detector = OutlierDetector(ts_day, "additive")

File ~/miniconda3/envs/data_analysisPy39/lib/python3.9/site-packages/kats/__init__.py:6
      1 # Copyright (c) Meta Platforms, Inc. and affiliates.
      2 #
      3 # This source code is licensed under the MIT license found in the
      4 # LICENSE file in the root directory of this source tree.
----> 6 from . import compat  # noqa # usort: skip
      7 from . import consts  # noqa # usort: skip
      8 from . import data  # noqa # usort: skip

File ~/miniconda3/envs/data_analysisPy39/lib/python3.9/site-packages/kats/compat/__init__.py:6
      1 # Copyright (c) Meta Platforms, Inc. and affiliates.
      2 #
      3 # This source code is licensed under the MIT license found in the
      4 # LICENSE file in the root directory of this source tree.
----> 6 from . import compat  # noqa # usort: skip
      7 from . import pandas  # noqa # usort: skip
      8 from . import statsmodels  # noqa # usort: skip

File ~/miniconda3/envs/data_analysisPy39/lib/python3.9/site-packages/kats/compat/compat.py:19
     14 from typing import Callable, Union
     16 from packaging import version as pv
---> 19 V = Union[str, "Version", pv.Version, pv.LegacyVersion]
     22 class Version:
     23     """Extend packaging Version to allow comparing to version strings.
     24 
     25     Wraps instead of extends, because pv.parse can return either a
     26     pv.Version or a pv.LegacyVersion.
     27     """

AttributeError: module 'packaging.version' has no attribute 'LegacyVersion'

How can I be able to use kats for that simple thing, without an error?

cbergmeir commented 1 year ago

Hi, I'm also new to Kats and ran into the same issue. It is caused by a wrong version of the "packaging" package. I was able to fix it with: conda install packaging=21.3

rohanfb commented 1 year ago

Fixed with 5d5c708d2975885d6f5ec24f5ed03a520bdcce99 but use the latest working build as there was another bug fixed after this.