Question

I set the Pdb debugger in my file as I always do like so import pdb; pdb.set_trace() and now I keep getting this traceback. I'm not sure what is the issue, and I don't see anything online about this anywhere.

Traceback (most recent call last):
  File "myfile.py", line 28, in <module>
    pdb.set_trace()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py", line 1251, in set_trace
    Pdb().set_trace(sys._getframe().f_back)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py",     line 63, in __init__
    cmd.Cmd.__init__(self, completekey, stdin, stdout)
TypeError: __init__() takes at most 2 arguments (4 given)
Was it helpful?

Solution

Check whether you have your own cmd.py. That prevent import of standard library cmd module.

Try following command:

python -c "import cmd; print(cmd.__file__)"

It should print something like:

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py

or

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.pyc

If there's your own version of cmd.py or cmd.pyc, rename it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top