Posting my own answer based on the one given by lgautier since that one did not work as is. I also made it a bit more general by passing nrow
instead of having it fixed.
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
ks = importr('ks')
kde_test = ks.kde_test
matr1 = [1., 3., 1., 3., 0.2, 1.5, 0.5, 1.3]
matr2 = [1., 3., 1., 3., 0.2, 1.5, 0.5, 1.3, 0.5, 4.6]
m1 = robjects.r.matrix(robjects.FloatVector(matr1), nrow=int(len(matr1)/2), byrow=True)
m2 = robjects.r.matrix(robjects.FloatVector(matr2), nrow=int(len(matr2)/2), byrow=True)
res = kde_test(x1 = m1, x2 = m2)
pval = res.rx2('pvalue')
print float(str(pval)[4:])
All credit goes to lgautier for proposing the solution even if it did not work at first.