Python文件打包时出现以下问题的解决办法:RecursionError: maximum ecursion depth exceeded

Python文件打包时出现以下问题的解决办法:RecursionError: maximum ecursion depth exceeded

一:Python打包办法

Python打包采用pyinstaller库进行打包,通过对源文件打包后,Python程序可以在没有安装Python的环境中运行,也可以作为一个独立的文件方便传递和管理。其安装的基本步骤如下:

(1)Win+R打开cmd命令窗口

(2)输入pyinstaller < Python源程序文件名>(C盘目录下)

如果目录不在C盘,则进行磁盘切换:C→G:

Python文件打包时出现以下问题的解决办法:RecursionError: maximum ecursion depth exceeded

(3)在安装时出现错误:RecursionError: maximum ecursion depth exceeded

这种情况采用如下的方法解决:

即在pyinstaller运行时生成的.spec文件(该文件可以用Python打开)中添加如下三行代码:

import os.path as osp
sys.setrecursionlimit(5000)
block_cipher = None

如下图所示:

Python文件打包时出现以下问题的解决办法:RecursionError: maximum ecursion depth exceeded

(4)在此基础上运行在cmd窗口运行下列命令:

Pyinstaller  <XXX.spec>

即可打包Python程序,其最终结果如图所示:

Python文件打包时出现以下问题的解决办法:RecursionError: maximum ecursion depth exceeded