Failure to debug my script

Hello,
I’m on Windows machine running Python in Git Bash
$ python --version
Python 3.11.0
I have an issue to run my simple script in debugger but it runs fine when I simply execute it.
Here’s my script:

import datetime

current_date = datetime.datetime.now().strftime("%Y-%m-%d")

print(current_date)

If I run it I have this:
2023-12-01

If I run it in debugger I have this:

$ python -m pdb debug.py
> c:\ev\sandbox\debug.py(2)<module>()
-> import datetime
(Pdb) b 6
Breakpoint 1 at c:\ev\sandbox\debug.py:6
(Pdb) c
Traceback (most recent call last):
  File "pdb.py", line 1768, in main
  File "pdb.py", line 1646, in _run
  File "bdb.py", line 597, in run
  File "<string>", line 1, in <module>
  File "C:\EV\SandBox\debug.py", line 2, in <module>
    import datetime
ModuleNotFoundError: No module named 'datetime'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> c:\ev\sandbox\debug.py(2)<module>()
-> import datetime
(Pdb)

Hence, I can't run my script in debugger.
How could I fix it?
I checked that modur 'datetime' is built-in and worked outside of debugger. 

Thanks

I have some update:
I used another Windows machine. I could use it only for testing. I used again Git Bash:


$ python3 --version
Python 3.11.5

I ran same script in debugger with no issue:

$ python3 -m pdb debug.py 
> \\10.9.214.183\landingzonebos\zzemptyzz\ev\debug.py(1)<module>()
-> import datetime
(Pdb) b 5
Breakpoint 1 at \\10.9.214.183\landingzonebos\zzemptyzz\ev\debug.py:5
(Pdb) c
> \\10.9.214.183\landingzonebos\zzemptyzz\ev\debug.py(5)<module>()
-> print(current_date)
(Pdb) s
2023-12-01
--Return--

Hence, the issue is definitely in my environment … but I have to use this particular machine. How could I fix it?
Thanks

datetime is a built in module from the standard library. I’d say reinstall python as something is wrong.

Hi @csm10495
I like your idea of re-installing python.
Well … in my case I use Azure Data Studio on Windows server. I installed Git Bash and use shell for all my needs. I see that Git Bash has also python … and I tried to use it … but as you see … it has an issue.
I don’t know how to unisntall python from Git Bash.
Maybe I would better install a new python application and put it in a path?
What python would you recommend me to install on Windows 2019?
Thanks

@csm10495
I realized that my server already has Anaconda installed.
It’s Python 3.10.9
I tried and it worked fine with my script.
Now I need only somehow make Anaconda default python on my machine.
Thanks for advice