marcelotduarte/cx_Freeze

.EXE File creating Issue

sahiljadhav123 opened this issue ยท 9 comments

module.code = loader.source_to_code(
^^^^^^^^^^^^^^^^^^^^^^
File "", line 1004, in source_to_code
File "", line 241, in _call_with_frames_removed
RecursionError: maximum recursion depth exceeded during compilation

hooks = import_module(f"cx_Freeze.hooks.{root_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sahil\AppData\Local\Programs\Python\Python311\Lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1206, in _gcd_import
File "", line 1178, in _find_and_load
File "", line 1140, in _find_and_load_unlocked
File "", line 1080, in _find_spec
File "", line 1504, in find_spec
File "", line 1476, in _get_spec
File "", line 1616, in find_spec
File "", line 1684, in _fill_cache
File "", line 1684, in
RecursionError: maximum recursion depth exceeded while calling a Python object

Still I am Getting Issue to build .exe file with both new version cx-Freeze==6.16.0.dev9 or cx-Freeze==6.15.13

try using in your setup.py:
sys.setrecursionlimit(sys.getrecursionlimit() * 10)

setup.py -
from cx_Freeze import setup, Executable

setup(
name="Purchase",
version="1.0",
description="Extraction Code",
executables=[Executable("main.py")]
)

error -

hooks = import_module(f"cx_Freeze.hooks.{root_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1206, in _gcd_import
File "", line 1178, in _find_and_load
File "", line 1140, in _find_and_load_unlocked
File "", line 1080, in _find_spec
File "", line 1504, in find_spec
File "", line 1476, in _get_spec
File "", line 1616, in find_spec
File "", line 1684, in _fill_cache
File "", line 1684, in
RecursionError: maximum recursion depth exceeded while calling a Python object

Please help For this - sys.setrecursionlimit(sys.getrecursionlimit() * 10)

I meant, to add it to the top of the setup.py:

from cx_Freeze import setup, Executable
import sys

sys.setrecursionlimit(sys.getrecursionlimit() * 10)

setup(
name="Purchase",
version="1.0",
description="Extraction Code",
executables=[Executable("main.py")]
)

yes its working Now But what is the Issue and why we need to add recursion limit Sir , and Thanks For Help

The default value is low, but it works in most cases.
https://docs.python.org/3/library/sys.html#sys.setrecursionlimit

You probably use a package that has a lot of imports. Are you using pytorch, scipy or some other big package?

yes but those package is not usefull for me right now if i uninstall this package then the error will be remove ??

You have two options:
uninstall
use excludes.

Thanks Sir For Help ๐Ÿ‘