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

688    Asked by AmyAvery in Python , Asked on Apr 23, 2021


Answered by Amy Avery

I think you are getting overflowerror: python int too large to convert to c long error message because 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 "", line 1, in
OverflowError: Python int too large to convert to C long
You can check this with the below code:
>>> import sys
>>> sys.maxsize
2147483647

To execute the numbers with larger precision, I would suggest you do not pass any int type which uses as bounded C integer behind the scenes. Use the default float:

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


Your Answer

Interviews

Parent Categories