Donnerstag, 10. Dezember 2015


Tried to debug my code by inserting this line:
 import ipdb; ipdb.set_trace()
Got an error like this:
/usr/local/lib/python2.7/dist-packages/pkg_resources/ AttributeError

 E           AttributeError: _dep_map

 Found a comment that said:
Ah, that means the real AttributeError is happening inside of the @property; the AttributeError being raised is after the fallback. Unfortunately, due to the way Python's attribute handling works, if there's an attribute error raised by a property getter, and the object has a __getattr__, then the real error is discarded and the __getattr__ is called instead.
So whatever error you're getting needs to be tracked down inside the @property;

Stepping through the code I found another error:
*** AttributeError: 'module' object has no attribute '_subx'
Which came from:
> /usr/lib/python2.7/
-> return _compile(pattern, flags).sub(repl, string, count)

(Pdb) pattern
<_sre.SRE_Pattern object at 0xb6afb270>
(Pdb) flags
(Pdb) ccc = _compile(pattern, flags)
(Pdb) ccc
<_sre.SRE_Pattern object at 0xb6afb270>
(Pdb) repl
(Pdb) string
(Pdb) count
(Pdb) ccc.sub(repl, string, count)
*** AttributeError: 'module' object has no attribute '_subx'
Something seemed wrong with the regex-lib. After removing the extra regex-lib via:
sudo python2.7 -mpip uninstall regex
I can use ipdb in my code again.

But was it really that regex-lib? On other code I could use ipdb without a problem. From the commented issue the solution was to change a custom parser-lib. So it may be something totally different for you. Look out for the exception-information from the _dep_map-property
def _dep_map(self):
most probably from an exception inside the exception handling.