Holiday module problem

34 views
Skip to first unread message

Eduardo Alejandro Jurschan

unread,
Mar 27, 2024, 1:13:00 PMMar 27
to PyScripter
Good afternoon:
I'm having a problem when I run this script with pyscripter

import datetime
import holidays

def ultimo_dia_habil(year, month):
    # Obtener todos los días del mes
    days_in_month = range(1, 32)
    last_day = None

    # Iterar sobre los días del mes en orden inverso
    for day in reversed(days_in_month):
        try_date = datetime.date(year, month, day)
        # Si es día laborable y no es feriado en Argentina, lo consideramos como el último día hábil
        if try_date.weekday() < 5 and try_date not in holidays.Argentina():
            last_day = try_date
            break

    return last_day

# Obtener el último día hábil del mes actual
fecha_actual = datetime.datetime.now()
ultimo_dia_habil_mes_actual = ultimo_dia_habil(fecha_actual.year, fecha_actual.month)

if ultimo_dia_habil_mes_actual:
    print("El último día hábil del mes actual es:", ultimo_dia_habil_mes_actual.strftime("%Y-%m-%d"))
else:
    print("No se encontró ningún día hábil este mes.")


This is the error:

*** Remote Interpreter Reinitialized ***
Traceback (most recent call last):
  File "D:\Documents\Clientes\AGENCIA EFE\Agencia EFE\Liquidacion de Sueldos\DESARROLLO\ART.80\holiday.py", line 13, in <module>
    import holidays
ModuleNotFoundError: No module named 'holidays


Would you help me resolve it?

Thks
Eduardo







PyScripter

unread,
Mar 27, 2024, 2:18:39 PMMar 27
to PyScripter
The holidays python module is not installed.  You need to do:
Tools, Tools, Install packages with pip, holidays

Eduardo Alejandro Jurschan

unread,
Mar 27, 2024, 3:40:47 PMMar 27
to PyScripter
Done!!
Thks!!

Ajisth

unread,
Apr 12, 2024, 10:21:03 AMApr 12
to PyScripter
hello to all im  new this group 
i dont know to use python please help me 
all to learn python , i shall be thank full to you all 
 btw my name is ajisth , hello to all

Ajisth

unread,
Apr 12, 2024, 10:22:18 AMApr 12
to PyScripter
i think you all know python im very jealous of you
Reply all
Reply to author
Forward
0 new messages