Downgrading to Python 3.11 is one of the solution for this issue but instead of reverting to Python 3.11, I tried by upgrading to Python 3.12.7 and it started working properly.