fixing python error: RuntimeError: maximum recursion depth exceeded in cmp
April 27th, 2007 by Lawrence David
if your python code produces the following error: “RuntimeError: maximum recursion depth exceeded in cmp,” try adding this line to the beginning of your code:
sys.setrecursionlimit(1500)
note that python’s default limit is 1000.
Tip gorth gold =), thanks have had some trouble with this for a while, solved now, thanks!
beautifull! Great Tip!
Sweet. Solved a problem I had been beating my head against that I was convinced was caused by something else.
Thanks.
Say hi to the ‘tvte for me.
J
HI
I´m having the error you mencioned..
Try to sove it the way you say, with “sys.setrecursionlimit(1500)” …
But first tell me : name ‘sys’ is not defined…
then i put import sys
and the error continues..
Can you help me?
Thanks
HI
i raised the value and it blows up
Thanks
segmentation fault…
When I tried this it said “NameError: name ‘sys’ is not defined”
put:
import sys
at the start of ur code.. to solve the sys NameError
If you are getting segfaults after increasing the recursion limit, it means that your code is stuck in an endless loop.
Good suggestion..thanks a lot..:)
Very great suggestion, i’ve modifying my code trying to solve that problem!
Thanks!
Thanks =D
Fixed the problem with Jinja2 install on C:\Python27\Lib\distutils\log.py. Had to set to 2000
What is the max value for setrecursionlimit still not working for Jinja2 install on
File “c:\python27\lib\ntpath.py”, line 127, in splitdrive
if p[1:2] == ‘:’:
RuntimeError: maximum recursion depth exceeded in cmp
New to python, trying to install flask
This is a mind-blastingly terrible idea.
Recursion limits are there for a reason; if it’s being exceeded, something is wrong… very wrong! And that wrongness should be corrected the right way (fixing the recursion) not by telling Python to ignore the error.
For any recursive problem there exists a non-recursive way to do it.
Thanks for this quick and dirty hack, works like a charm.
~Jeff
Your blog is really cool to me and your topics are very relevant. I was browsing around and came across something you might find interesting. I was guilty of 3 of them with my sites. “99% of site owners are guilty of these 5 mistakes”. http://tinyurl.com/dxoyke8 You will be suprised how easy they are to fix.
After importing the above line, my command is working but it is not generating any sequence diagram. Any idea why is it so?
where i can find the cmp? is this a file?
does it locate at /usr/bin?
and how to edit it?
wow.. thanks a lot
Thanks a lot.. You save me big time
thx a lot you’re great !
I look for the solution for a long time . you’re the best !
Thanks a tonne…
what if I give it float(‘inf’)?
Thanks a lot !!! Great tip !!
878003 324935 There is noticeably a bundle to know about this. I assume you created certain nice points in functions also. 326630