最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - TypeError raised when importing fbprophet - Stack Overflow

programmeradmin1浏览0评论

Condition: any python command will have the same error. For example if run this simple command python -V , it will generate the same error.

I am using:

  • conda/miniconda3 version : 24.5.0
  • spyder-kernels version : 3.0.2
  • python version : 3.12.8

My spyder-env path: D:\Spyder6.0.3\envs\my-env-test

I have set the PYTHONPATH to:

and python interpreter to:

My python scripts:

import pandas as pd
import matplotlib.pyplot as plt
from fbprophet import Prophet

df = pd.read_csv('data/dau.csv', parse_dates=['Date'], index_col='Date')

df_prophet = df.reset_index().rename(columns={'Date': 'ds', 'New Users': 'y'})

model = Prophet()
model.fit(df_prophet)

future = model.make_future_dataframe(periods=10)

forecast = model.predict(future)

model.plot(forecast)
plt.show()

Console output:

%runfile D:/_SpyderAnalysis/New_User.py --wdir
Unexpected exception formatting exception. Falling back to standard exception
Traceback (most recent call last):
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\customize\code_runner.py", line 506, in _exec_code
    exec_encapsulate_locals(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\customize\utils.py", line 209, in exec_encapsulate_locals
    exec_fun(compile(code_ast, filename, "exec"), globals, None)
  File "d:\_spyderanalysis\new_user.py", line 3, in <module>
    from fbprophet import Prophet
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\__init__.py", line 8, in <module>
    from fbprophet.forecaster import Prophet
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\forecaster.py", line 17, in <module>
    from fbprophet.make_holidays import get_holiday_names, make_holidays_df
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\make_holidays.py", line 14, in <module>
    import fbprophet.hdays as hdays_part2
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\hdays.py", line 17, in <module>
    from holidays import WEEKEND, HolidayBase, Turkey
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\holidays\__init__.py", line 22, in <module>
    from holidays.holiday_base import *
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\holidays\holiday_base.py", line 45, in <module>
    CategoryArg = Union[str, Iterable[str]]
TypeError: 'ABCMeta' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\interactiveshell.py", line 2105, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1396, in structured_traceback
    return FormattedTB.structured_traceback(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1287, in structured_traceback
    return VerboseTB.structured_traceback(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1140, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1030, in format_exception_as_a_whole
    self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else []
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1081, in get_records
    style = get_style_by_name("default")
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\utils\style.py", line 134, in create_style_class
    class StyleClass(Style):
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\utils\style.py", line 136, in StyleClass
    styles = create_pygments_dict(color_scheme_dict)
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\utils\style.py", line 46, in create_pygments_dict
    fon_c, fon_fw, fon_fs = color_scheme["normal"]
TypeError: string indices must be integers

And because any python command/script I run will generates the same error. I don't think the error are coming from my python script.

Can anyone help me?

Note: I am still learning how to use spyder and this is my first setup on Spyder.

fbprophet version 0.7.1(it's the latest one available)

python version from conda cmd:

Condition: any python command will have the same error. For example if run this simple command python -V , it will generate the same error.

I am using:

  • conda/miniconda3 version : 24.5.0
  • spyder-kernels version : 3.0.2
  • python version : 3.12.8

My spyder-env path: D:\Spyder6.0.3\envs\my-env-test

I have set the PYTHONPATH to:

and python interpreter to:

My python scripts:

import pandas as pd
import matplotlib.pyplot as plt
from fbprophet import Prophet

df = pd.read_csv('data/dau.csv', parse_dates=['Date'], index_col='Date')

df_prophet = df.reset_index().rename(columns={'Date': 'ds', 'New Users': 'y'})

model = Prophet()
model.fit(df_prophet)

future = model.make_future_dataframe(periods=10)

forecast = model.predict(future)

model.plot(forecast)
plt.show()

Console output:

%runfile D:/_SpyderAnalysis/New_User.py --wdir
Unexpected exception formatting exception. Falling back to standard exception
Traceback (most recent call last):
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\customize\code_runner.py", line 506, in _exec_code
    exec_encapsulate_locals(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\customize\utils.py", line 209, in exec_encapsulate_locals
    exec_fun(compile(code_ast, filename, "exec"), globals, None)
  File "d:\_spyderanalysis\new_user.py", line 3, in <module>
    from fbprophet import Prophet
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\__init__.py", line 8, in <module>
    from fbprophet.forecaster import Prophet
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\forecaster.py", line 17, in <module>
    from fbprophet.make_holidays import get_holiday_names, make_holidays_df
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\make_holidays.py", line 14, in <module>
    import fbprophet.hdays as hdays_part2
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\fbprophet\hdays.py", line 17, in <module>
    from holidays import WEEKEND, HolidayBase, Turkey
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\holidays\__init__.py", line 22, in <module>
    from holidays.holiday_base import *
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\holidays\holiday_base.py", line 45, in <module>
    CategoryArg = Union[str, Iterable[str]]
TypeError: 'ABCMeta' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\interactiveshell.py", line 2105, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1396, in structured_traceback
    return FormattedTB.structured_traceback(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1287, in structured_traceback
    return VerboseTB.structured_traceback(
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1140, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1030, in format_exception_as_a_whole
    self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else []
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\IPython\core\ultratb.py", line 1081, in get_records
    style = get_style_by_name("default")
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\utils\style.py", line 134, in create_style_class
    class StyleClass(Style):
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\utils\style.py", line 136, in StyleClass
    styles = create_pygments_dict(color_scheme_dict)
  File "D:\Spyder6.0.3\envs\my-env-test\lib\site-packages\spyder_kernels\utils\style.py", line 46, in create_pygments_dict
    fon_c, fon_fw, fon_fs = color_scheme["normal"]
TypeError: string indices must be integers

And because any python command/script I run will generates the same error. I don't think the error are coming from my python script.

Can anyone help me?

Note: I am still learning how to use spyder and this is my first setup on Spyder.

fbprophet version 0.7.1(it's the latest one available)

python version from conda cmd:

Share Improve this question edited Feb 5 at 9:47 lmtaq 4583 silver badges14 bronze badges asked Feb 2 at 11:28 noobseenoobsee 9722 gold badges17 silver badges32 bronze badges 9
  • Because the holidays package has a bug – roganjosh Commented Feb 2 at 11:31
  • do i really need the holidays package? how to "not use it" ? – noobsee Commented Feb 2 at 11:31
  • holidays is being called by fbprophet so, no, you can't remove the dependency. You could try upgrading either/both of the packages and see whether that helps. I'm curious about the source code now because TypeError: 'ABCMeta' object is not subscriptable seems very odd from what looks like a type annotation – roganjosh Commented Feb 2 at 11:34
  • What version of python are you using? – roganjosh Commented Feb 2 at 11:36
  • I attached my python script on the question, or what you need is the source code from holiday_base.py file? Anyway, I already use latest fbprophet version 0.7.1 (just added the screenshot on my question) – noobsee Commented Feb 2 at 11:40
 |  Show 4 more comments

1 Answer 1

Reset to default 0

The root cause for the issue is unclear to me, however, to unblock you, you could consider installing the prophet package rather than fbprophet.

Note that fbprophet corresponds to older versions of the lib, prior to v1.0.

V1.0 was released in 2021 and any other versions launched since then are available on the prophet package (ref).

发布评论

评论列表(0)

  1. 暂无评论