ImportError: cannot import name 'Xlnk' from 'pynq'

Hi, I am using Pynq- Z2 with image v2.7.
I want to rebuild some projects from pynq community. But, most of them were deployed on older versions where Xlnk was there. But, now I cannot use their codes.
I got to know that now we have allocate() in place of Xlnk.
But, not sure exact syntax. Can anyone help how can I change the older code to get it working now.


  • def cleanup(self):
    xlnk = Xlnk()

  • self.library = library
    self.xlnk = Xlnk()

  • def copy_array(self, x, dtype=np.int32):
    “”“Copy numpy array to contiguous memory.
    x: np.array
    Input numpy array, not necessarily in contiguous memory.
    dtype : type
    Data type for the give numpy array.
    Physically contiguous memory.
    size = x.shape
    data_buffer = self.xlnk.cma_array(shape=size, dtype=dtype, cacheable=self.cacheable)
    np.copyto(data_buffer, x.astype(dtype), casting=“unsafe”)
    return data_buffer

I have the same issue, but I found that V2.7 has removed Xlnk. The info is from Releases · Xilinx/PYNQ · GitHub

Removed Xlnk allocator and libraries for edge devices (replaced by XRT allocation)
However, I don’t know how to use XRT to replace Xlnk.

Hi, You can find information about how to use allocate in the v2.7 manual:

Kind regards

There are some Allocate examples here: