Window passed, Linux failed with "SetArray argument 1: incorrect buffer type, expected q but received l"

I tried to run such python codes:

import vtk
import numpy as np

arraySize = 81
lineArray = np.array([ 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0,
12, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 11,
12, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 22,
13, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 33,
13, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 45,
13, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 57],dtype = np.int64)

vtkIarr = vtk.vtkIdTypeArray()
vtkIarr.SetArray(lineArray,arraySize,1)

when I tried it on win 10 with python3, everything was ok.
But when I tried it on CentOS 8 with python3, it returned an error message as follows:
“vtkIarr.SetArray(lineArray,arraySize,1)
TypeError: SetArray argument 1: incorrect buffer type, expected q but received l”

This is quite strange to me. Can anyone help?

A little detective work shows what the difference is. On Windows:

>>> import numpy as np
>>> np.dtype('int64').char
'q'

And on Linux:

>>> import numpy as np
>>> np.dtype('int64').char
'l'

Explanation: on Windows, numpy’s ‘int64’ dtype is the C ‘long long’ type.
But on Linux, numpy’s ‘int64’ dtype is the C ‘long’ type.

For VTK, the 64-bit vtkIdType is ‘long long’ for Windows and Linux. So the type check succeeds on Windows, but fails on Linux.

If you want to make a numpy array that is compatible with vtkIdTypeArray, then use this, which should work on Windows and on Linux:

np.array([...], dtype=np.longlong)

Thanks very much!