I am trying a get a list public holidays for a country using the Python Holidays package. I have tried following the steps on the Git Repo and a number of other tutorial websites but I keep getting:
AttributeError: module 'holidays' has no attribute 'UnitedKingdom'
I installed the package pip install holidays
Then followed this example from geeksforgeeks:
from datetime import date
import holidays
uk_holidays = holidays.UnitedKingdom()
for ptr in holidays.UnitedKingdom(years = 2018).items():
print(ptr)
I have also tried changing the country to another one specified in the documentation, but It still throws the same AttributeError.
I fairly new to working with python so I am not really sure what I am doing wrong. Any help is greatly appreciated. Thank you
Maybe try installing via anaconda? https://docs.conda.io/en/latest/miniconda.html
First create a conda environment (named py37 below, name it how you wish), then perform the installation within the environment and execute the script. There may be some weird thing in your base python installation causing the library to not work.
conda create --name py37 python=3.7
conda activate py37
conda install -c conda-forge holidays
After this, run the code just as below. If you're using a text editor, you'll need to open that editor from the environment. Or just run from a python kernel through the command line.