Ticket #286 (closed Defect: fixed)
Predict GAM/GLM From ArcGIS Rasters tools fail with RPy_RException: Error: package/namespace load failed for 'mgcv'
|Reported by:||jjr8||Owned by:||jjr8|
|Component:||Core - R Interop||Version:|
Description (last modified by jjr8) (diff)
In this scenario, a message box comes up prior to the RPy_RException with the title "python.exe - Unable To Locate Component" and the message "This application has failed to start because Rlapack.dll was not found. Re-installing the application may fix this problem." After you click ok, the RPy_RException occurs.
The complete output from ArcGIS looks like this:
Executing (Predict GAM From Rasters): GAMPredictFromArcGISRasters C:\HabModExample\Statistics\model.rdata C:\HabModExample\Oceanography\s2004_Bathymetry\s2004;C:\HabModExample\Oceanography\MODIS_SST\Monthly\sst\2003\sst200310;C:\HabModExample\Oceanography\SeaWiFS_MODIS_Combined_Chlorophyll\Monthly\log_chlo\2003\chlo200310 Bathymetry;SST;LogChl C:\HabModExample\HabitatMaps\probability GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]] "-80.5 31.5 -64.5 39.5" 8.33333333333333E-02 # # C:\HabModExample\HabitatMaps\stderror C:\HabModExample\HabitatMaps\binary 0.551820106136 true Start Time: Wed Sep 24 12:57:39 2008 Running script GAMPredictFromArcGISRasters... Warning: package 'rgdal' was built under R version 2.7.2 Warning: package 'sp' was built under R version 2.7.2 RPy_RException: Error: package/namespace load failed for 'mgcv' Obtaining additional debugging information. This may cause this tool to hang. If you do not see any additional messages after one minute, halt its execution. Error in script GAMPredictFromArcGISRasters. Error in executing: cmd.exe /C C:\Python24\Lib\SITE-P~1\GeoEco\ARCGIS~1\Scripts\GAMPRE~1.PY "C:\HabModExample\Statistics\model.rdata" "C:\HabModExample\Oceanography\s2004_Bathymetry\s2004;C:\HabModExample\Oceanography\MODIS_SST\Monthly\sst\2003\sst200310;C:\HabModExample\Oceanography\SeaWiFS_MODIS_Combined_Chlorophyll\Monthly\log_chlo\2003\chlo200310" "Bathymetry;SST;LogChl" "C:\HabModExample\HabitatMaps\probability" "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]" "-80.5 31.5 -64.5 39.5" "8.33333333333333E-02" "#" "#" "C:\HabModExample\HabitatMaps\stderror" "C:\HabModExample\HabitatMaps\binary" "0.551820106136" "true" Failed to execute (Predict GAM From Rasters). End Time: Wed Sep 24 12:58:57 2008 (Elapsed Time: 1 minutes 18 seconds)
The problem is that R's Sys.setenv/Sys.getenv functions only seem to support maximum length of around 1024 for a given environment variable. The PATH variable seemed to only allow 1019 characters. (Perhaps the string "PATH=" plus 1019 more? Or "PATH" + 1019 more + a terminating null character?) The machine that experienced the error had a very long PATH--many things were installed on the machine--so when GeoEco used rpy to instantiate the R interpeter, rpy attached the R paths on the end of PATH but they were ignored by R because they were beyond the 1019 limit. Then, when mgcv tried to load Rlapack.DLL, it failed because it wasn't in any of the directories listed in the PATH that ocurred before the 1019 limit.
There is no 100% satisfactory solution to this problem. My solution is to move the directories that rpy appends to the end of PATH to the front of PATH. This gets around the problem. But who knows what other directories are now beyond the 1019 limit.
This is really a bug in R. Time permitting, I will see if I can get the R development team to fix it.