Ask Your Question

Can't Install R Packages in Sage

asked 2013-04-14 13:28:46 -0500

jaia gravatar image

I'm running Sage 5.8 on Ubuntu 12.10 and am trying to install some R packages within Sage. However, when I enter


I get a green line and nothing happens. I am not asked what repository I'd like to use; when I specified a repository, I still got a green line and nothing happened. If I leave out the package name, I get a pop-up asking what package I want to install but nothing after that. What should I do?

edit retag flag offensive close merge delete


Ordinarily this should work fine - I've done it live in talks. Did you download a binary or build from source? Any other information about your install would be very helpful.

kcrisman gravatar imagekcrisman ( 2013-04-14 16:14:08 -0500 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2013-04-14 13:36:04 -0500

Launch R instead of Sage, by using the following command in a terminal window.

$ sage -R

You can then install the R packages. Once installed, you can use them in Sage.

edit flag offensive delete link more


That partly works, but now I get warnings about the R include directory being empty and then an error that says compilation failed.

jaia gravatar imagejaia ( 2013-04-14 13:44:54 -0500 )edit

OK, solved it. I installed the new spkg at (For anyone who doesn't know how to do this, in Ubuntu I ran sudo sage -i .)

jaia gravatar imagejaia ( 2013-04-14 16:15:46 -0500 )edit

@jaia: Did you have bad hardcoded paths before, or was there some other problem? We would love to add you to the reviewer list at if this solved the problem based on what that package was for!

kcrisman gravatar imagekcrisman ( 2013-04-16 07:48:07 -0500 )edit

answered 2013-09-14 19:37:09 -0500

JoalHeagney gravatar image

updated 2013-09-14 19:37:54 -0500

I had these issues when first using the binary versions of sagemath. Installing wouldn't work, and the "include directories are empty" message would pop up in sage -R.

Solved it by using the command: sage -fr to force-rebuild the R package. Make sure you have all the build dependencies for libpng, libjpeg, cairo, etc. installed.

Then I could use install.packages("...") from sage -R, the notebook in R mode, or %r-cell mode with no issues.

Now I use a source build/updated version of sage instead.

edit flag offensive delete link more


Good catch - sometimes it's not clear whether users are using a binary or Sage built from source!

kcrisman gravatar imagekcrisman ( 2013-09-16 02:47:48 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-04-14 13:28:46 -0500

Seen: 559 times

Last updated: Sep 14 '13