问题
I am trying to use PyInstaller to convert my python3.5 project into an .exe file My main file is SegTool.py
This is my .spec file:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['SegTool.py'],
pathex=['consts.py', 'FetalMRI_about.py', 'FetalMRI_mainwindow.py', 'FetalMRI_workspace.py', 'image_label.py', 'main_window.py', 'scan_file.py', 'segment3d_itk.py', 'Shapes.py', 'workspace.py', 'C:\\Users\\Keren Meron\\Documents\\School Work\\Fetal MRI\\FetalSegBrainTool'],
binaries=[],
datas=[('images', 'images')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_n_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='SegTool',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='SegTool')
Maybe I don't understand enough the hooks and dependencies related, but I am getting a crash:
File "C:\Users\Keren Meron\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\ast.py", line 245, in visit
return visitor(node)
File "C:\Users\Keren Meron\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\ast.py", line 253, in generic_visit
self.visit(item)
File "C:\Users\Keren Meron\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\ast.py", line 245, in visit
return visitor(node)
RecursionError: maximum recursion depth exceeded
The output (DEBUG and INFO are on) right before the traceback:
10923 INFO: Caching module hooks...
10937 INFO: Analyzing SegTool.py
13458 INFO: Processing pre-safe import module hook six.moves
14204 INFO: Processing pre-safe import module hook win32com
14205 DEBUG: win32com: extending __path__ with dir 'C:\\Users\\Keren Meron\\WinPython-64bit-3.5.3.1Qt5\\python-3.5.3.amd64\\lib\\site-packages\\win32comext'
14604 INFO: Processing pre-find module path hook distutils
16281 INFO: Processing pre-find module path hook site
16284 INFO: site: retargeting to fake-dir 'C:\\Users\\Keren Meron\\WinPython-64bit-3.5.3.1Qt5\\python-3.5.3.amd64\\lib\\site-packages\\PyInstaller\\fake-modules'
40968 INFO: Processing pre-safe import module hook requests.packages.urllib3.packages.six.moves
51591 DEBUG: load_module: SyntaxError in 'C:\\Users\\Keren Meron\\WinPython-64bit-3.5.3.1Qt5\\python-3.5.3.amd64\\lib\\site-packages\\jinja2\\asyncsupport.py'
Please help, what do I need to do to fix this?
Thank you
回答1:
This might be too late, but I faced this issue too, and fixed it by adding a couple of lines of code in the spec file at the top:
# -*- mode: python -*-
import sys
sys.setrecursionlimit(5000)
block_cipher = None
Hopefully, this fixes you issue too, if it is still open!
回答2:
Try the following command to force reinstall!
pip install --force-reinstall --no-binary :all: pyinstaller
回答3:
pip install --upgrade setuptools
Hopefully this fixes your issue.
来源:https://stackoverflow.com/questions/50076325/pyinstaller-maximum-recursion-error-after-pre-safe-import-module-hook-six-moves