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

**URL:** https://discourse.vtk.org/t/window-passed-linux-failed-with-setarray-argument-1-incorrect-buffer-type-expected-q-but-received-l/6364
**Category:** Support
**Created:** [August 12, 2021, 8:34pm UTC](https://discourse.vtk.org/t/window-passed-linux-failed-with-setarray-argument-1-incorrect-buffer-type-expected-q-but-received-l/6364 "2021-08-12T20:34:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Hongying\_Feng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hongying_feng/32/3794_2.png) [@Hongying\_Feng](https://discourse.vtk.org/u/Hongying_Feng)
#### Post date: [August 12, 2021, 8:34pm UTC](https://discourse.vtk.org/t/window-passed-linux-failed-with-setarray-argument-1-incorrect-buffer-type-expected-q-but-received-l/6364/1 "2021-08-12T20:34:52Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [August 13, 2021, 1:23am UTC](https://discourse.vtk.org/t/window-passed-linux-failed-with-setarray-argument-1-incorrect-buffer-type-expected-q-but-received-l/6364/2 "2021-08-13T01:23:01Z")

</div>

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

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

```

And on Linux:

```auto
>>> 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:

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

```

---

<div class="post-metadata">

### Author: ![Hongying\_Feng](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hongying_feng/32/3794_2.png) [@Hongying\_Feng](https://discourse.vtk.org/u/Hongying_Feng)
#### Post date: [August 13, 2021, 1:25am UTC](https://discourse.vtk.org/t/window-passed-linux-failed-with-setarray-argument-1-incorrect-buffer-type-expected-q-but-received-l/6364/3 "2021-08-13T01:25:13Z")

</div>

Thanks very much!
