install R packages

123 views
Skip to first unread message

Aleksey Gogolev

unread,
Jul 14, 2009, 4:41:55 AM7/14/09
to sage-s...@googlegroups.com
Hello!

I tried to install package "cluster" for R and got this:

----------------------------------------------------------------------
| Sage Version 4.0.2, Release Date: 2009-06-18 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: r.install_package("cluster")
Error: object "sage1" not found
sage: r.install_package("cluster")
Error: object "sage2" not found
sage: r.install_package("cluster")

Can somebody give a hint what is wrong?

Thanks in advance.

Message has been deleted

Aleksey Gogolev

unread,
Jul 14, 2009, 5:46:48 AM7/14/09
to sage-s...@googlegroups.com
Hi Minh,

Thank you!
I entered the command and got the same output as yours, but still no luck :(
After I restarted Sage and tried to load library I got the ImportError:

sage:r.library("cluster")
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)

/root/sage-4.0.2-linux-CentOS_release_5.2_Final-i686-Linux/<ipython
console> in <module>()

/root/sage-4.0.2-linux-CentOS_release_5.2_Final-i686-Linux/local/lib/python2.5/site-packages/sage/interfaces/r.pyc
in library(self, library_name)
554 ret = self.eval('require("%s")'%library_name)
555 if 'there is no package' in ret:
--> 556 raise ImportError, "there is no package called
'%s'"%library_name
557 else:
558 try:

ImportError: there is no package called 'cluster'

I guess it's also some newbie mistake. I googled it but didn't find a
reason why R doesn't "see" the package. Any hint will be appreciated.


2009/7/14 Minh Nguyen <nguye...@gmail.com>:
>
> Hi Aleksey,
> The correct command is r.install_packages(); notice the extra "s". For example:
>
> ----------------------------------------------------------------------
> | Sage Version 4.1, Release Date: 2009-07-09                         |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: r.install_packages("cluster")
> 0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (0major+212minor)pagefaults 0swaps
>
> R version 2.6.1 (2007-11-26)
> Copyright (C) 2007 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
>> options(repos="http://cran.r-project.org/"); install.packages("cluster")
> trying URL 'http://cran.r-project.org/src/contrib/cluster_1.12.0.tar.gz'
> Content type 'application/x-gzip' length 215041 bytes (210 Kb)
> opened URL
> ==================================================
> downloaded 210 Kb
>
> WARNING: ignoring environment value of R_HOME
> .: 121: Can't open /scratch/mvngu/sage-4.1/local/lib/R/share/sh/dcf.sh
>
> The downloaded packages are in
>        /tmp/Rtmpq9wIvZ/downloaded_packages
> Updating HTML index of packages in '.Library'
> Warning messages:
> 1: In install.packages("cluster") :
>  installation of package 'cluster' had non-zero exit status
> 2: In tools:::unix.packages.html(.Library) :
>  cannot create HTML package index
>>
> Please restart Sage or restart the R interface (via r.restart()) in
> order to use 'cluster'.
>
> --
> Regards
> Minh Van Nguyen
>
> >
>
Message has been deleted

David Joyner

unread,
Jul 14, 2009, 7:00:21 AM7/14/09
to sage-s...@googlegroups.com
On Tue, Jul 14, 2009 at 6:20 AM, Minh Nguyen<nguye...@gmail.com> wrote:
>
> Hi Aleksey,
>

...

>
> Not at all; you're not doing anything wrong. This is a known error;
> see ticket #6379 at
>
> http://www.sagetrac.org/sage_trac/ticket/6379
>
> which already has a patch and positive review. But after applying that
> patch, installing cluster, restart Sage, and import the library
> cluster, Sage still doesn't recognize the cluster package. For
> example, here is what I did under Sage 4.1:
>
> sage: hg_sage.apply("http://www.sagetrac.org/sage_trac/raw-attachment/ticket/6379/trac_6379-Rdoctest.patch")
> <applying the above patch>
> sage: exit
> Exiting SAGE (CPU time 0m0.09s, Wall time 0m18.86s).
> [mvngu@sage sage-4.1-sage.math.washington.edu-x86_64-Linux]$ ./sage -br main
> <now install cluster>
> sage: r.install_packages("cluster")
> <now restart Sage>
> sage: exit
> Exiting SAGE (CPU time 0m0.50s, Wall time 0m22.15s).
> [mvngu@sage sage-4.1-sage.math.washington.edu-x86_64-Linux]$ ./sage -br main
> <now import the package cluster>
> sage: r.library("cluster")
> ---------------------------------------------------------------------------
> ImportError                               Traceback (most recent call last)
>
> /home/mvngu/.sage/temp/sage.math.washington.edu/16587/_home_mvngu__sage_init_sage_0.py
> in <module>()
>
> /scratch/mvngu/sage-4.1-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/interfaces/r.pyc
> in library(self, library_name)
>    557             # not all warnings (e.g. "closing unused
> connection 3") are fatal
>
>    558             if 'library(' in ret:       # locale-independent key-word
> --> 559                 raise ImportError, "%s"%ret
>    560         else:
>    561             try:
>
> ImportError: Loading required package: cluster
> Warning message:
> In library(package, lib.loc = lib.loc, character.only = TRUE,
> logical.return = TRUE,  :
>  there is no package called 'cluster'


I'm no expert on R by any means but if I'm understanding this thread,
and your (Minh's) comments on #6379 correctly, a new ticket
should be opened up separate from
http://www.sagetrac.org/sage_trac/ticket/6379.
If you agree, I can do that if you like.


>
> The error message is much "friendlier" than previously. However, from
> the output I suspect that cluster has not been installed in a
> directory where R (the one bundled with Sage) recognizes. Just a
> guess.
>

...
Message has been deleted

David Joyner

unread,
Jul 14, 2009, 7:16:38 AM7/14/09
to sage-s...@googlegroups.com
On Tue, Jul 14, 2009 at 7:02 AM, Minh Nguyen<nguye...@gmail.com> wrote:
>
> Hi David,
>
> On Tue, Jul 14, 2009 at 9:00 PM, David Joyner<wdjo...@gmail.com> wrote:
>
> <SNIP>
>
>> I'm no expert on R by any means but if I'm understanding this thread,
>> and your (Minh's) comments on #6379 correctly, a new ticket
>> should be opened up separate from
>> http://www.sagetrac.org/sage_trac/ticket/6379.
>> If you agree, I can do that if you like.
>
> Yes, can you please do that? Thank you very much.


This is http://trac.sagemath.org/sage_trac/ticket/6532
I also cc'd one of the R maintainers.

Aleksey Gogolev

unread,
Jul 14, 2009, 9:08:09 AM7/14/09
to sage-s...@googlegroups.com
Hi Minh,

2009/7/14 Minh Nguyen <nguye...@gmail.com>:
>
> Hi Aleksey,
>
> On Tue, Jul 14, 2009 at 7:46 PM, Aleksey
> Gogolev<aleksey...@gmail.com> wrote:
>>
>> Hi Minh,
>>
>> Thank you!
>> I entered the command and got the same output as yours, but still no luck :(
>> After I restarted Sage and tried to load library I got the ImportError:
>>
>> sage:r.library("cluster")
>> ---------------------------------------------------------------------------
>> ImportError                               Traceback (most recent call last)
>>
>> /root/sage-4.0.2-linux-CentOS_release_5.2_Final-i686-Linux/<ipython
>> console> in <module>()
>>
>> /root/sage-4.0.2-linux-CentOS_release_5.2_Final-i686-Linux/local/lib/python2.5/site-packages/sage/interfaces/r.pyc
>> in library(self, library_name)
>>    554         ret = self.eval('require("%s")'%library_name)
>>    555         if 'there is no package' in ret:
>> --> 556             raise ImportError, "there is no package called
>> '%s'"%library_name
>>    557         else:
>>    558             try:
>>
>> ImportError: there is no package called 'cluster'
>>
>> I guess it's also some newbie mistake.
>
> Not at all; you're not doing anything wrong. This is a known error;
> see ticket #6379 at
>
> http://www.sagetrac.org/sage_trac/ticket/6379
>
> which already has a patch and positive review. But after applying that
> patch, installing cluster, restart Sage, and import the library
> cluster, Sage still doesn't recognize the cluster package. For
> example, here is what I did under Sage 4.1:
>
> sage: hg_sage.apply("http://www.sagetrac.org/sage_trac/raw-attachment/ticket/6379/trac_6379-Rdoctest.patch")
> <applying the above patch>
> sage: exit
> Exiting SAGE (CPU time 0m0.09s, Wall time 0m18.86s).
> [mvngu@sage sage-4.1-sage.math.washington.edu-x86_64-Linux]$ ./sage -br main
> <now install cluster>
> sage: r.install_packages("cluster")
> <now restart Sage>
> sage: exit
> Exiting SAGE (CPU time 0m0.50s, Wall time 0m22.15s).
> [mvngu@sage sage-4.1-sage.math.washington.edu-x86_64-Linux]$ ./sage -br main
> <now import the package cluster>
> sage: r.library("cluster")
> ---------------------------------------------------------------------------
> ImportError                               Traceback (most recent call last)
>
> /home/mvngu/.sage/temp/sage.math.washington.edu/16587/_home_mvngu__sage_init_sage_0.py
> in <module>()
>
> /scratch/mvngu/sage-4.1-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/interfaces/r.pyc
> in library(self, library_name)
>    557             # not all warnings (e.g. "closing unused
> connection 3") are fatal
>
>    558             if 'library(' in ret:       # locale-independent key-word
> --> 559                 raise ImportError, "%s"%ret
>    560         else:
>    561             try:
>
> ImportError: Loading required package: cluster
> Warning message:
> In library(package, lib.loc = lib.loc, character.only = TRUE,
> logical.return = TRUE,  :
>  there is no package called 'cluster'
>
> The error message is much "friendlier" than previously. However, from
> the output I suspect that cluster has not been installed in a
> directory where R (the one bundled with Sage) recognizes. Just a
> guess.
>
> Anyway, from the error message you posted above, it looks to me that
> you have installed Sage as root. In fact in the root home directory
> /root. This is *strongly* discouraged for security reasons. If you're
> the only person using Sage on your system, then you should install
> Sage as a regular user, not as a superuser. If other people on your
> system will be using Sage, then you can install Sage in
> /usr/local/bin/ or something like that, but I don't recommend the
> directory /root.

Thanks! It's not up to me where Sage is installed, I'll tell about
this my admin.

> Regards
> Minh Van Nguyen
>
> >
>
Reply all
Reply to author
Forward
0 new messages