Python maximum recursion depth exceeded while calling a Python object (gevent的SSL无限递归错误)的问题解决
今天给以前写的python脚本用pyinstaller打包的时候,居然报错了
-
-
File "d:\programdata\anaconda3\lib\ast.py", line 253, in visit
-
return visitor(node)
-
File "d:\programdata\anaconda3\lib\ast.py", line 261, in generic_visit
-
self.visit(item)
-
File "d:\programdata\anaconda3\lib\ast.py", line 253, in visit
-
return visitor(node)
-
File "d:\programdata\anaconda3\lib\ast.py", line 263, in generic_visit
-
self.visit(value)
-
File "d:\programdata\anaconda3\lib\ast.py", line 253, in visit
-
return visitor(node)
-
RecursionError: maximum recursion depth exceeded
看上去似乎是某个库自己递归遍历玩的太嗨了,超过了python的栈高度限制
搜索了一番,很快找到了解决办法: https://stackoverflow.com/questions/38977929/pyinstaller-creating-exe-runtimeerror-maximum-recursion-depth-exceeded-while-ca
在此总结下解决步骤:
1)pyinstaller -F xxx.py
这一步肯定会报上述错误导致失败,但是会产生一个xxx.spec文件
2)在xxx.spec文件中增加两行(添加在原文件第二行):
-
import sys
-
sys.setrecursionlimit(5000)
3)pyinstaller xxx.spec
打包成功。
-