Reputation: 19
When I insert import pdb; pdb.set_trace()
in my code, it shows an error message:
'module' object has attribute 'set_trace'
In the pdb.py
file, there is the def set_trace()
function. How can it not work?
Has anyone had the same problem and knows how to solve this?
Upvotes: 1
Views: 4751
Reputation: 61
if the python file that you are running is code.py
please change the name. For some reasons code.py
or pdb.py
files can not use pdb package.
Upvotes: 3
Reputation: 3134
If your script is named pdb.py
, that will cause this error. Change the name of your script.
Upvotes: 0
Reputation: 6677
What Python version are you using?
I can reproduce that error if I try to import pdb; pdb.set_trace()
on Python 3.8
.
Try to use breakpoint()
instead (has basically the same purpose), it worked for me!
Cheers,
Andres
Upvotes: 0