Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import name 'easter' from 'holidays'

I am trying to import fbprophet on Python Anaconda, however, I get this error:

 ImportError: cannot import name 'easter' from 'holidays' 

Can anyone suggest what might have gone wrong?

Code:

from fbprophet import fbprophet
like image 335
ALAUKIK HARSH Avatar asked Feb 10 '20 06:02

ALAUKIK HARSH


3 Answers

I'm using anaconda, and the only solution that worked for me was:

Replace line 16 in fbprophet/hdays.py (\AppData\Local\Continuum\anaconda3\Lib\site-packages\fbprophet\hdays.py):

from holidays import WEEKEND, HolidayBase, easter, rd

to

from holidays import WEEKEND, HolidayBase
from dateutil.easter import easter
from dateutil.relativedelta import relativedelta as rd
like image 74
Susana Isabel Santos Avatar answered Oct 19 '22 09:10

Susana Isabel Santos


This is a recent known error that has been reported. (look here for the thread).

The reason and outline is -

"easter" is not a holidays function, but instead a dateutil library function. Until the previous version of holidays (0.9.12) it was "accidentally" accessible, due to it being imported in holidays.py (main library module, now removed in favour of single country modules), but its direct reference made in prophet is basically wrong (same goes for WEEKEND, HolidayBase etc., not meant for being accessed from outside holidays library).
In order to fix fbprophet, replacing the erroring import with

from dateutil.easter import easter

like image 42
Karan Shishoo Avatar answered Oct 19 '22 07:10

Karan Shishoo


I faced this problem, googled and solved it. For solution, do the followings;

  1. Open python3.6/site-packages/fbprophet/hdays.py file.
  2. Replace

    from holidays import WEEKEND, HolidayBase, easter, rd

to

    from holidays import WEEKEND, HolidayBase
    from dateutil.easter import easter
    from dateutil.relativedelta import relativedelta as rd
like image 1
tolgabuyuktanir Avatar answered Oct 19 '22 09:10

tolgabuyuktanir