I would like to run this Python code from R:
>>> import nlmpy 
>>> nlm = nlmpy.mpd(nRow=50, nCol=50, h=0.75) 
>>> nlmpy.exportASCIIGrid("raster.asc", nlm)
Nlmpy is a Python package to build neutral landscape models. The example comes from the website
To run this Python code from R, I 'm trying to use the package rPithon. However, I obtain this error message:
if (pithon.available()) 
{ 
  nRow <- 50 
  nCol <- 50 
  h <- 0.75 
  # this file contains the definition of function concat 
  pithon.load("C:/Users/Anaconda2/Lib/site-packages/nlmpy/nlmpy.py") 
  pithon.call( "mpd", nRow, nCol, h) 
} else { 
  print("Unable to execute python") 
} 
Error in pithon.get("_r_call_return", instance.name = instname) : 
Couldn't retrieve variable: Traceback (most recent call last): 
File "C:/Users/Documents/R/win-library/3.3/rPithon/pythonwrapperscript.py", line 110, in <module> 
reallyReallyLongAndUnnecessaryPrefix.data = json.dumps([eval(reallyReallyLongAndUnnecessaryPrefix.argData)]) 
File "C:\Users\ANACON~1\lib\json\__init__.py", line 244, in dumps 
return _default_encoder.encode(obj) 
File "C:\Users\ANACON~1\lib\json\encoder.py", line 207, in encode 
chunks = self.iterencode(o, _one_shot=True) 
File "C:\Users\ANACON~1\lib\json\encoder.py", line 270, in iterencode 
return _iterencode(o, 0) 
File "C:\Users\ANACON~1\lib\json\encoder.py", line 184, in default 
raise TypeError(repr(o) + " is not JSON serializable") 
TypeError: array([[ 0.36534654,  0.31962481,  0.44229946, ...,  0.11513079, 
0.07156331,  0.00286971], [ 0.41534291,  0.41333479,  0.48118995, ...,  0.19203674, 
0.04192771,  0.03679473], [ 0.5188
Is this error caused by a syntax issue in my code ? I work with the Anaconda 4.2.0 platform for Windows which uses the Python 2.7 version.