3

This is a common issue with certain libraries like pandas. I read that the solution may be by adding:

import sys
sys.setrecursionlimit(3000) 

in the setup.py .Where is this setup file? I have created the py file and located it in the directory that i want to turn to exe but i don't know where i should add that piece of code?

There is also this fix:

hook-pandas.py
hiddenimports = ['pandas._libs.tslibs.timedeltas',
'pandas._libs.tslibs.nattype',
'pandas._libs.tslibs.np_datetime',
'pandas._libs.skiplist']

but I don't know how to make this hook even though I read the post in the official site. If you can, make a clear answer about how to solve this.

2
  • You can set it in any file. just run the file recursion limit will be updated Commented Jul 3, 2018 at 13:16
  • I should add this to the file with the code? the post said not the file with the code but the setup. I don't know, nothing changes if I place it with the code. Commented Jul 3, 2018 at 13:18

4 Answers 4

1

You don't need add it to any special file.
Just add it into your current python file and run. You can see the difference by running getrecursionlimit() before and after running the command.

import sys
print(sys.getrecursionlimit())   # recursionlimit before 
# 1000
sys.setrecursionlimit(3000) 
print(sys.getrecursionlimit())    # recursionlimit after 
# 3000
Sign up to request clarification or add additional context in comments.

9 Comments

I made a py with this. I ran it and then tried again to turn the other py to exe and it failed again. What is going on? it didn't change anything
I am sorry. This will only change in current context. Pardon.
Maximum recursion depth exceeded
You place the above code in your current python file
I did it but didn't change anything. Also tried with the spec file with the same error.
|
0

setup.py files are created by you, to define the packaging information used for your project. I'd strongly recommend reading The Packaging Python Projects tutorial, as the topic is much larger than can be covered here.

All you do is add those lines to the top of your setup.py file, prior to any other imports (which might end up being monkeypatched by Pyinstaller, causing the problem).

2 Comments

How can I make it turn to exe and proceed without the error?
@user10026983: My understanding was that the error was at packaging time. You need to make your setup.py with the recursion fix, then follow the Pyinstaller docs for using it as normal.
0

For me, it worked simply by adding the following lines at the beginning of the .spec file that pyinstaller creates:

import sys
sys.setrecursionlimit(2000)

1 Comment

As the spec file you referenced during the process, when you add the code to that?
0

To supplement the answers by others for anyone attempting to increase the maximum recursion limit:

Use the import sys sys.setrecursionlimit(5000) snippet in the my_code.spec file, not your my_code.py file. Additionally, this file is re-written every time you run the pyinstaller command on a .py file, thus once you have edited it after an unsuccessful run, running pyinstaller my_code.py will take you back to square one.

Instead, run pyinstaller my_code.spec to keep your latest recursion limit setting.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.