[R-sig-Geo] problem loading sp using Rpy (python)

Roger Bivand Roger.Bivand at nhh.no
Tue Oct 9 11:12:39 CEST 2007


On Mon, 8 Oct 2007, Jorge de Jesus wrote:

> Hi to all
> I am working on Python and Rpy to make automatic interpolations. I need
> to use the sp library of R.
>
> When Rpy calls my R scripts it creates an error saying that the sp
> package can't be loaded. But inside the R environment everything works ok.

Is Rpy respecting your R_LIBS setting - that is, is it finding the library 
in which the sp package is installed? From the output below, I think you 
should read up on having multiple libraries, and maybe using .libPaths() 
to manage them from within R. Installing contributed packages in the main 
R library is not wise, if you need control of what your system is doing.

>
> When I removed sp and then reinstalled I got the following error:
>

You have not included the verbatim code, please do, otherwise interpreting 
the output is guesswork.

> trying URL
> 'http://rm.mirror.garr.it/mirrors/CRAN/src/contrib/sp_0.9-14.tar.gz'
> Content type 'application/x-gzip' length 359180 bytes
> opened URL
> ==================================================
> downloaded 350Kb
>
> * Installing *source* package 'sp' ...

You did intend to install the *source* package? How was your R installed, 
from source (always most robust)?

Please always include sessionInfo() output. In such cases, please also try 
several mirrors too, just in case a particular mirror is not carrying a 
good copy.

> ** libs
> Error in library.dynam(lib, package, package.lib) :
> shared library 'sp' not found
> In addition: Warning messages:
> 1: package 'sp' contains no R code in: loadNamespace(package,
> c(which.lib.loc, lib.loc), keep.source = keep.source)
> 2: S3 methods ?as.data.frame.SpatialPoints?,
> ?as.data.frame.SpatialPixels?, ?as.data.frame.SpatialGrid?,
> ?as.data.frame.SpatialPointsDataFrame?,
> ?as.data.frame.SpatialPixelsDataFrame?,
> ?as.data.frame.SpatialGridDataFrame?,
> ?as.data.frame.SpatialLinesDataFrame?,
> ?as.data.frame.SpatialPolygonsDataFrame?, ?as.data.frame.GridTopology?,
> ?as.matrix.SpatialGridDataFrame?, ?as.matrix.SpatialPixelsDataFrame?,
> ?cbind.SpatialGridDataFrame?, ?contour.SpatialPixelsDataFrame?,
> ?contour.SpatialGridDataFrame?, ?dim.SpatialPointsDataFrame?,
> ?image.SpatialPixelsDataFrame?, ?image.SpatialGridDataFrame?,
> ?lines.Line?, ?lines.Lines?, ?lines.SpatialLines?,
> ?lines.SpatialLinesDataFrame?, ?names.SpatialPointsDataFrame?,
> ?names.SpatialPixelsDataFrame?, ?names.SpatialGridDataFrame?,
> ?names.SpatialLinesDataFrame?, ?names.SpatialPolygonsDataFrame?,
> ?names<-.SpatialPointsDataFrame?, ?names<-.SpatialPolygonsDa [... truncated]
> During startup - Warning message:
> package sp in options("defaultPackages") was not found
> gcc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include
> -I/usr/local/include -fpic -g -O2 -c gcdist.c -o gcdist.o
> gcc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include
> -I/usr/local/include -fpic -g -O2 -c init.c -o init.o
> gcc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include
> -I/usr/local/include -fpic -g -O2 -c pip.c -o pip.o
> gcc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include
> -I/usr/local/include -fpic -g -O2 -c Rcentroid.c -o Rcentroid.o
> gcc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include
> -I/usr/local/include -fpic -g -O2 -c zerodist.c -o zerodist.o
> gcc -std=gnu99 -shared -L/usr/local/lib -o sp.so gcdist.o init.o pip.o
> Rcentroid.o zerodist.o -L/usr/local/lib/R/lib -lR
> ** R
> ** data
> ** demo
> ** inst
> ** preparing package for lazy loading
> Error in code2LazyLoadDB(package, lib.loc = lib.loc, keep.source =
> keep.source, :
> name space must not be loaded.
> Execution halted
> ERROR: lazy loading failed for package 'sp'
> ** Removing '/usr/local/lib/R/library/sp'
>
> The downloaded packages are in
> /tmp/RtmpttNUa3/downloaded_packages
> Warning message:
> installation of package 'sp' had non-zero exit status in: install.packages()
>
>
> Also I managed to get some extra info from Rpy, where it says the sp
> library isn't loaded because of R_alloc() and some namespace problem(?).
>
> Can anyone give me some help on understanding what is the problem and
> how to fix it ??
>
> Thanks
> Jorge
>
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list