“greykite.framework.templates.forecaster”导入出现类型错误 - 虚拟环境配置错误

问题描述 投票:0回答:0

我尝试从 greykite 导入某些内容时遇到以下类型错误:

TypeError:这是一个 python-holidays 实体加载器类。出于实体继承的目的,请导入您想要直接派生的类:例如,

from holidays.countries import Entity
from holidays.financial import Entity

进口线路:

from greykite.framework.templates.forecaster import Forecaster

贝娄是我的虚拟环境:

name: C:\Users\Nes_X\Desktop\Time Series Forecasting Product\env
channels:
  - conda-forge
  - defaults
dependencies:
  - aiofiles=22.1.0=py38haa95532_0
  - aiosqlite=0.18.0=py38haa95532_0
  - anyio=3.5.0=py38haa95532_0
  - appdirs=1.4.4=pyhd3eb1b0_0
  - argon2-cffi=21.3.0=pyhd3eb1b0_0
  - argon2-cffi-bindings=21.2.0=py38h2bbff1b_0
  - asttokens=2.0.5=pyhd3eb1b0_0
  - attrs=22.1.0=py38haa95532_0
  - babel=2.11.0=py38haa95532_0
  - backcall=0.2.0=pyhd3eb1b0_0
  - beautifulsoup4=4.12.2=py38haa95532_0
  - blas=1.0=mkl
  - bleach=4.1.0=pyhd3eb1b0_0
  - bottleneck=1.3.5=py38h080aedc_0
  - brotli=1.0.9=h2bbff1b_7
  - brotli-bin=1.0.9=h2bbff1b_7
  - brotlipy=0.7.0=py38h2bbff1b_1003
  - ca-certificates=2023.05.30=haa95532_0
  - certifi=2023.7.22=py38haa95532_0
  - cffi=1.15.1=py38h2bbff1b_3
  - charset-normalizer=2.0.4=pyhd3eb1b0_0
  - cmdstan=2.32.1=hcde1630_0
  - cmdstanpy=1.1.0=pyhd8ed1ab_0
  - colorama=0.4.6=py38haa95532_0
  - comm=0.1.2=py38haa95532_0
  - contourpy=1.0.5=py38h59b6b97_0
  - convertdate=2.4.0=pyhd8ed1ab_0
  - cryptography=41.0.2=py38h31511bf_0
  - cycler=0.11.0=pyhd3eb1b0_0
  - cython=0.29.35=py38hd77b12b_0
  - debugpy=1.5.1=py38hd77b12b_0
  - decorator=5.1.1=pyhd3eb1b0_0
  - defusedxml=0.7.1=pyhd3eb1b0_0
  - entrypoints=0.4=py38haa95532_0
  - ephem=4.1.4=py38h91455d4_0
  - executing=0.8.3=pyhd3eb1b0_0
  - fonttools=4.25.0=pyhd3eb1b0_0
  - freetype=2.12.1=ha860e81_0
  - giflib=5.2.1=h8cc25b3_3
  - glib=2.69.1=h5dc1a3c_2
  - gst-plugins-base=1.18.5=h9e645db_0
  - gstreamer=1.18.5=hd78058f_0
  - holidays=0.29=pyhd8ed1ab_0
  - icc_rt=2022.1.0=h6049295_2
  - icu=58.2=ha925a31_3
  - idna=3.4=py38haa95532_0
  - importlib-metadata=6.0.0=py38haa95532_0
  - importlib_metadata=6.0.0=hd3eb1b0_0
  - importlib_resources=5.2.0=pyhd3eb1b0_1
  - intel-openmp=2023.1.0=h59b6b97_46319
  - ipykernel=6.19.2=py38hd4e2768_0
  - ipython=8.12.0=py38haa95532_0
  - ipython_genutils=0.2.0=pyhd3eb1b0_1
  - ipywidgets=8.0.4=py38haa95532_0
  - jedi=0.18.1=py38haa95532_1
  - jinja2=3.1.2=py38haa95532_0
  - joblib=1.2.0=py38haa95532_0
  - jpeg=9e=h2bbff1b_1
  - json5=0.9.6=pyhd3eb1b0_0
  - jsonschema=4.17.3=py38haa95532_0
  - jupyter=1.0.0=py38haa95532_8
  - jupyter_client=8.1.0=py38haa95532_0
  - jupyter_console=6.6.3=py38haa95532_0
  - jupyter_core=5.3.0=py38haa95532_0
  - jupyter_events=0.6.3=py38haa95532_0
  - jupyter_server=2.5.0=py38haa95532_0
  - jupyter_server_fileid=0.9.0=py38haa95532_0
  - jupyter_server_terminals=0.4.4=py38haa95532_1
  - jupyter_server_ydoc=0.8.0=py38haa95532_1
  - jupyter_ydoc=0.2.4=py38haa95532_0
  - jupyterlab=3.6.3=py38haa95532_0
  - jupyterlab_pygments=0.1.2=py_0
  - jupyterlab_server=2.22.0=py38haa95532_0
  - jupyterlab_widgets=3.0.5=py38haa95532_0
  - kiwisolver=1.4.4=py38hd77b12b_0
  - krb5=1.19.4=h5b6d351_0
  - lerc=3.0=hd77b12b_0
  - libbrotlicommon=1.0.9=h2bbff1b_7
  - libbrotlidec=1.0.9=h2bbff1b_7
  - libbrotlienc=1.0.9=h2bbff1b_7
  - libclang=14.0.6=default_hb5a9fac_1
  - libclang13=14.0.6=default_h8e68704_1
  - libdeflate=1.17=h2bbff1b_0
  - libffi=3.4.4=hd77b12b_0
  - libhwloc=2.9.1=h51c2c0f_0
  - libiconv=1.16=h2bbff1b_2
  - libogg=1.3.5=h2bbff1b_1
  - libpng=1.6.39=h8cc25b3_0
  - libsodium=1.0.18=h62dcd97_0
  - libtiff=4.5.0=h6c2663c_2
  - libvorbis=1.3.7=he774522_0
  - libwebp=1.2.4=hbc33d0d_1
  - libwebp-base=1.2.4=h2bbff1b_1
  - libxml2=2.10.3=h0ad7f3c_0
  - libxslt=1.1.37=h2bbff1b_0
  - lunarcalendar=0.0.9=py_0
  - lxml=4.9.2=py38h2bbff1b_0
  - lz4-c=1.9.4=h2bbff1b_0
  - m2-bash=4.3.042=5
  - m2-coreutils=8.25=102
  - m2-filesystem=2016.04=4
  - m2-gcc-libs=5.3.0=4
  - m2-gmp=6.1.0=3
  - m2-libiconv=1.14=3
  - m2-libintl=0.19.7=4
  - m2-msys2-runtime=2.5.0.17080.65c939c=3
  - m2-sed=4.2.2=3
  - m2w64-binutils=2.25.1=5
  - m2w64-bzip2=1.0.6=6
  - m2w64-crt-git=5.0.0.4636.2595836=2
  - m2w64-gcc=5.3.0=6
  - m2w64-gcc-ada=5.3.0=6
  - m2w64-gcc-fortran=5.3.0=6
  - m2w64-gcc-libgfortran=5.3.0=6
  - m2w64-gcc-libs=5.3.0=7
  - m2w64-gcc-libs-core=5.3.0=7
  - m2w64-gcc-objc=5.3.0=6
  - m2w64-gmp=6.1.0=2
  - m2w64-headers-git=5.0.0.4636.c0ad18a=2
  - m2w64-isl=0.16.1=2
  - m2w64-libiconv=1.14=6
  - m2w64-libmangle-git=5.0.0.4509.2e5a9a2=2
  - m2w64-libwinpthread-git=5.0.0.4634.697f757=2
  - m2w64-make=4.1.2351.a80a8b8=2
  - m2w64-mpc=1.0.3=3
  - m2w64-mpfr=3.1.4=4
  - m2w64-pkg-config=0.29.1=2
  - m2w64-toolchain=5.3.0=7
  - m2w64-toolchain_win-64=2.5.0=h57928b3_0
  - m2w64-tools-git=5.0.0.4592.90b8472=2
  - m2w64-windows-default-manifest=6.4=3
  - m2w64-winpthreads-git=5.0.0.4634.697f757=2
  - m2w64-zlib=1.2.8=10
  - markupsafe=2.1.1=py38h2bbff1b_0
  - matplotlib=3.7.1=py38haa95532_1
  - matplotlib-base=3.7.1=py38hf11a4ad_1
  - matplotlib-inline=0.1.6=py38haa95532_0
  - mistune=0.8.4=py38he774522_1000
  - mkl=2023.1.0=h8bd8f75_46356
  - mkl-service=2.4.0=py38h2bbff1b_1
  - mkl_fft=1.3.6=py38hf11a4ad_1
  - mkl_random=1.2.2=py38hf11a4ad_1
  - msys2-conda-epoch=20160418=1
  - munkres=1.1.4=py_0
  - nbclassic=0.5.5=py38haa95532_0
  - nbclient=0.5.13=py38haa95532_0
  - nbconvert=6.5.4=py38haa95532_0
  - nbformat=5.7.0=py38haa95532_0
  - nest-asyncio=1.5.6=py38haa95532_0
  - notebook=6.5.4=py38haa95532_0
  - notebook-shim=0.2.2=py38haa95532_0
  - numexpr=2.8.4=py38h7b80656_1
  - numpy=1.24.3=py38h79a8e48_1
  - numpy-base=1.24.3=py38h8a87ada_1
  - openssl=1.1.1u=h2bbff1b_0
  - packaging=23.0=py38haa95532_0
  - pandocfilters=1.5.0=pyhd3eb1b0_0
  - parso=0.8.3=pyhd3eb1b0_0
  - patsy=0.5.3=py38haa95532_0
  - pcre=8.45=hd77b12b_0
  - pickleshare=0.7.5=pyhd3eb1b0_1003
  - pillow=9.4.0=py38hd77b12b_0
  - pip=23.1.2=py38haa95532_0
  - pkgutil-resolve-name=1.3.10=py38haa95532_0
  - platformdirs=2.5.2=py38haa95532_0
  - ply=3.11=py38_0
  - pmdarima=2.0.3=py38h2bbff1b_0
  - pooch=1.4.0=pyhd3eb1b0_0
  - prometheus_client=0.14.1=py38haa95532_0
  - prompt-toolkit=3.0.36=py38haa95532_0
  - prompt_toolkit=3.0.36=hd3eb1b0_0
  - prophet=1.1.4=py38h589431e_0
  - psutil=5.9.0=py38h2bbff1b_0
  - pthreads-win32=2.9.1=hfa6e2cd_3
  - pure_eval=0.2.2=pyhd3eb1b0_0
  - pycparser=2.21=pyhd3eb1b0_0
  - pygments=2.15.1=py38haa95532_1
  - pymeeus=0.5.12=pyhd8ed1ab_0
  - pyopenssl=23.2.0=py38haa95532_0
  - pyparsing=3.0.9=py38haa95532_0
  - pyqt=5.15.7=py38hd77b12b_0
  - pyqt5-sip=12.11.0=py38hd77b12b_0
  - pyrsistent=0.18.0=py38h196d8e1_0
  - pysocks=1.7.1=py38haa95532_0
  - python=3.8.17=h6244533_0
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - python-fastjsonschema=2.16.2=py38haa95532_0
  - python-json-logger=2.0.7=py38haa95532_0
  - python_abi=3.8=2_cp38
  - pytz=2022.7=py38haa95532_0
  - pywin32=305=py38h2bbff1b_0
  - pywinpty=2.0.10=py38h5da7b33_0
  - pyyaml=6.0=py38h2bbff1b_1
  - pyzmq=25.1.0=py38hd77b12b_0
  - qt-main=5.15.2=he8e5bd7_8
  - qt-webengine=5.15.9=hb9a9bb5_5
  - qtconsole=5.4.2=py38haa95532_0
  - qtpy=2.2.0=py38haa95532_0
  - qtwebkit=5.212=h2bbfb41_5
  - requests=2.29.0=py38haa95532_0
  - rfc3339-validator=0.1.4=py38haa95532_0
  - rfc3986-validator=0.1.1=py38haa95532_0
  - scikit-learn=1.2.2=py38hd77b12b_1
  - scipy=1.10.1=py38hdcfc7df_1
  - send2trash=1.8.0=pyhd3eb1b0_1
  - setuptools=67.8.0=py38haa95532_0
  - sip=6.6.2=py38hd77b12b_0
  - six=1.16.0=pyhd3eb1b0_1
  - sniffio=1.2.0=py38haa95532_1
  - soupsieve=2.4=py38haa95532_0
  - sqlite=3.41.2=h2bbff1b_0
  - stack_data=0.2.0=pyhd3eb1b0_0
  - statsmodels=0.14.0=py38h9128911_0
  - tbb=2021.9.0=h91493d7_0
  - terminado=0.17.1=py38haa95532_0
  - threadpoolctl=2.2.0=pyh0d69192_0
  - tinycss2=1.2.1=py38haa95532_0
  - tk=8.6.12=h2bbff1b_0
  - toml=0.10.2=pyhd3eb1b0_0
  - tomli=2.0.1=py38haa95532_0
  - tornado=6.2=py38h2bbff1b_0
  - tqdm=4.65.0=pyhd8ed1ab_1
  - traitlets=5.7.1=py38haa95532_0
  - typing-extensions=4.6.3=py38haa95532_0
  - typing_extensions=4.6.3=py38haa95532_0
  - ucrt=10.0.22621.0=h57928b3_0
  - urllib3=1.26.16=py38haa95532_0
  - vc=14.2=h21ff451_1
  - vc14_runtime=14.36.32532=hfdfe4a8_17
  - vs2015_runtime=14.36.32532=h05e6639_17
  - wcwidth=0.2.5=pyhd3eb1b0_0
  - webencodings=0.5.1=py38_1
  - websocket-client=0.58.0=py38haa95532_4
  - wheel=0.38.4=py38haa95532_0
  - widgetsnbextension=4.0.5=py38haa95532_0
  - win_inet_pton=1.1.0=py38haa95532_0
  - winpty=0.4.3=4
  - xz=5.4.2=h8cc25b3_0
  - y-py=0.5.9=py38hb6bf4ef_0
  - yaml=0.2.5=he774522_0
  - ypy-websocket=0.8.2=py38haa95532_0
  - zeromq=4.3.4=hd77b12b_0
  - zipp=3.11.0=py38haa95532_0
  - zlib=1.2.13=h8cc25b3_0
  - zstd=1.5.5=hd43e919_0
  - pip:
      - cvxpy==1.3.2
      - dill==0.3.7
      - ecos==2.0.12
      - exceptiongroup==1.1.2
      - future==0.18.3
      - greykite==0.4.0
      - holidays-ext==0.0.8
      - iniconfig==2.0.0
      - lunarcalendar-ext==0.0.1
      - osqp==0.6.1
      - overrides==7.3.1
      - pandas==1.2.5
      - plotly==5.15.0
      - pluggy==1.2.0
      - pytest==7.4.0
      - pytest-runner==6.0.0
      - scs==3.2.3
      - tenacity==8.2.2
      - testfixtures==7.1.0
prefix: C:\Users\Nes_X\Desktop\Time Series Forecasting Product\env

以下完整错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 6
      4 import matplotlib.pyplot as plt
      5 from greykite.framework.templates.autogen.forecast_config import *
----> 6 from greykite.framework.templates.forecaster import Forecaster
      7 from greykite.framework.templates.model_templates import ModelTemplateEnum
      8 from greykite.common.features.timeseries_features import *

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\greykite\framework\templates\forecaster.py:37
     35 from greykite.common.logging import log_message
     36 from greykite.common.python_utils import unique_elements_in_list
---> 37 from greykite.framework.pipeline.pipeline import ForecastResult
     38 from greykite.framework.pipeline.pipeline import forecast_pipeline
     39 from greykite.framework.pipeline.utils import get_basic_pipeline

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\greykite\framework\pipeline\pipeline.py:47
     45 from greykite.framework.constants import COMPUTATION_N_JOBS
     46 from greykite.framework.constants import CV_REPORT_METRICS_ALL
---> 47 from greykite.framework.input.univariate_time_series import UnivariateTimeSeries
     48 from greykite.framework.output.univariate_forecast import UnivariateForecast
     49 from greykite.framework.pipeline.utils import get_basic_pipeline

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\greykite\framework\input\univariate_time_series.py:41
     39 from greykite.common.time_properties import describe_timeseries
     40 from greykite.common.time_properties import get_canonical_data
---> 41 from greykite.common.viz.timeseries_plotting import add_groupby_column
     42 from greykite.common.viz.timeseries_plotting import flexible_grouping_evaluation
     43 from greykite.common.viz.timeseries_plotting import grouping_evaluation

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\greykite\common\viz\timeseries_plotting.py:32
     29 from plotly.colors import DEFAULT_PLOTLY_COLORS
     31 from greykite.common import constants as cst
---> 32 from greykite.common.features.timeseries_features import build_time_features_df
     33 from greykite.common.logging import LoggingLevelEnum
     34 from greykite.common.logging import log_message

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\greykite\common\features\timeseries_features.py:31
     29 import numpy as np
     30 import pandas as pd
---> 31 from holidays_ext import get_holidays as get_hdays
     32 from scipy.special import expit
     34 from greykite.common import constants as cst

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\holidays_ext\get_holidays.py:13
      9 import warnings
     11 import pandas as pd
---> 13 from holidays_ext import holidays_ext
     14 import holidays
     17 def get_holiday(
     18         country_list: List[str],
     19         years: List[int]) -> dict:

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\holidays_ext\holidays_ext.py:1072
   1068 class GE(Georgia):
   1069     pass
-> 1072 class UnitedStates(OldUnitedStates):
   1073     """Overrides United States by adding Halloween."""
   1074     def __init__(self, **kwargs):

File ~\Desktop\Time Series Forecasting Product\env\lib\site-packages\holidays\registry.py:172, in EntityLoader.__init__(self, path, *args, **kwargs)
    170 """Set up a lazy loader."""
    171 if args:
--> 172     raise TypeError(
    173         "This is a python-holidays entity loader class. "
    174         "For entity inheritance purposes please import a class you "
    175         "want to derive from directly: e.g., "
    176         "`from holidays.countries import Entity` or "
    177         "`from holidays.financial import Entity`."
    178     )
    180 entity_path = path.split(".")
    182 self.entity = None

TypeError: This is a python-holidays entity loader class. For entity inheritance purposes please import a class you want to derive from directly: e.g., `from holidays.countries import Entity` or `from holidays.financial import Entity`.

如有任何帮助,我们将不胜感激,

谢谢。

我尝试在 conda 虚拟环境中重新安装假期包,认为这与它有关,但无济于事。

python conda typeerror virtualenv importerror
© www.soinside.com 2019 - 2024. All rights reserved.