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