close

[Solved] “OverflowError: Python int too large to convert to C long” on windows but not mac

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error “OverflowError: Python int too large to convert to C long” on windows but not mac in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How “OverflowError: Python int too large to convert to C long” on windows but not mac Error Occurs?

Today I get the following error “OverflowError: Python int too large to convert to C long” on windows but not mac in python.

How To Solve “OverflowError: Python int too large to convert to C long” on windows but not mac Error ?

  1. How To Solve “OverflowError: Python int too large to convert to C long” on windows but not mac Error ?

    To Solve “OverflowError: Python int too large to convert to C long” on windows but not mac Error To take numbers with larger precision, don't pass an int type which uses a bounded C integer behind the scenes. Use the default float:

  2. “OverflowError: Python int too large to convert to C long” on windows but not mac

    To Solve “OverflowError: Python int too large to convert to C long” on windows but not mac Error To take numbers with larger precision, don't pass an int type which uses a bounded C integer behind the scenes. Use the default float:

Solution 1

You can use dtype=np.int64 instead of dtype=int

Solution 2

You’ll get that error once your numbers are greater than sys.maxsize:

>>> p = [sys.maxsize]
>>> preds[0] = p
>>> p = [sys.maxsize+1]
>>> preds[0] = p
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C long

You can confirm this by checking:

>>> import sys
>>> sys.maxsize
2147483647

To take numbers with larger precision, don’t pass an int type which uses a bounded C integer behind the scenes. Use the default float:

>>> preds = np.zeros((1, 3))

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read