opencpu does not show installed packages - r

Let me confess first I am new to Docker / opencpu world. here is the issue.
I installed Docker from opencpu site on my windows 10 box.
I was able to successfully run the docker by "docker run --name myDocker -t -p 80:80 -p 8004:8004 opencpu/rstudio".
I successfully installed my R package by "R CMD INSTALL /tmp/AnotherPackage_0.1.0.tar.gz".
Only issue now is I cant see my Package in http://localhost/ocpu/test/. so in below figure I cant see my package in right box (which shows all the other packages).
If I do /library/AnotherPackage in Endpoint text box I can see my package's description etc..

You probably installed the package in another library. Can you show us the output of your R CMD INSTALL line? In particular the final line that starts with installing to....
To install into the global library, either install as user opencpu:
sudo su opencpu
R CMD INSTALL /tmp/AnotherPackage_0.1.0.tar.gz
Or install as root:
sudo -i
R CMD INSTALL /tmp/AnotherPackage_0.1.0.tar.gz

I think you are running it as opencpu user, which means user installed packages are in /ocpu/user/{username}/library/{pkgname}/. See here how to get a root shell so that your package is in /ocpu/library/{pkgname}/ as you expected.

Related

Install packages from source failing - Dockerfile

I am trying to install some packages from source (including package that I have created that installed fine with R console or even when R CMD install.
However, while building docker-image using a docker file. I get this error with for this line in the docker file
RUN R -e 'install.packages("RcppDIUtilsPackage_1.0.tar.gz",repos=NULL,type="source")'
I also tried many other commands including R CMD INSTALL all work fine to install the package except within the docker image build.
Here is the error i am encountering.
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: invalid package ‘RcppDIUtilsPackage_1.0.tar.gz’
Error: ERROR: no packages specified
Warning message:
In install.packages("RcppDIUtilsPackage_1.0.tar.gz", repos = NULL, :
installation of package ‘RcppDIUtilsPackage_1.0.tar.gz’ had non-zero exit status
Thanks!!
Edit: The Dockerfile
FROM rocker/r-ver:3.4.4
WORKDIR /home/ubuntu/projects/DService
RUN apt-get update -qq && apt-get install -y \
libssl-dev \
libcurl4-gnutls-dev
RUN R -e "install.packages('plumber')"
RUN R -e "install.packages('Rcpp')"
RUN R -e 'install.packages("RcppDIUtilsPackage_1.0.tar.gz",repos=NULL,type="source")'
COPY / /
EXPOSE 8000
CMD ["Rscript", "DService.R"]
command: sudo docker build --no-cache -t dservice-docker-image .
This is an indirect solution to your problem, because I was not able to resolve the same issue.
The root of the issue may have something to do with the host environment that created the Docker image from the Dockerfile. Specifically, the R instance that is spun up to install the local packages may not being able to access the path to where your local packages are stored.
The solution for me was to just avoid local packages. Move any local repositories to remote repositories, and reference them in the Dockerfile instead. e.g.
RUN R -e "devtools::install_github('dmanuge/shinyFilesWidget') ; system('echo 14')"
After that, rebuilt your Docker image and run it accordingly. While this is not a direct solution, I reached the critical threshold of debugging and needed to move on. :)

Installing R packages on Amazon Linux EC2 instance

I am learning to use RSelenium in an EC2 instance, and I found this handy guide on doing so - https://rpubs.com/grahamplace/rselenium-ec2 - however the guide focuses on an Ubuntu instance and I am using an Amazon Linux Instance. In order to install RSelenium, the guide says I must externally (outside of R but ssh'd into my EC2 instance) install the packages xml (XML i think, case sensitive) and RCurl. The guide's relevant lines of code are:
sudo apt-get install r-cran-xml
sudo apt-get install r-cran-RCurl
however, since I'm in an Amazon Linux instance, I tried:
sudo yum install r-cran-xml
sudo yum install r-cran-RCurl
for which I get the following error:
No package r-cran-RCurl available.
Error: Nothing to do
Note: I was successful in installing R on my machine (my instance), and I am able to simply type R to launch R in the EC2 instance.
Note2: install.packages('XML') and install.packages('RCurl') with R launched do not work either.
Any help appreciated with this, thanks!
the amazon linux R package has a different name:
sudo yum install -y R
then you tried (in R) install.packages(c('XML','RCurl')), but the installation failed.
as you discovered and describe in the comment below, you needed to install an additional amazon linux package, libxml2-devel, in order to install.packages('XML') successfully.
this is what I get when I run sudo yum install -y R
No package R available.
Error: Nothing to do
R is available in Amazon Linux Extra topic "R3.4"
To use, run
sudo amazon-linux-extras install R3.4
Learn more at
https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras

How to install wordcloud in python3.6?

I installed wordcloud via conda in Windows 64
conda install -c conda-forge word cloud
but that is python 3.4.
I want to install word cloud in python 3.6
but i did search the google.
but it is not effect. so please teach me....
Anaconda Python 3.6 version
For Windows
==== Installation of wordcloud package ====
download wordcloud‑1.3.2‑cp36‑cp36m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
Copy the file to your current working directory
Open command prompt from Tools
python -m pip install wordcloud-1.3.2-cp36-cp36m-win_amd64.whl
It should work now
For MAC
pip install wordcloud
There is a solution, you can download a third party package for Python 3. Following the below steps helped me solve the problem.
Wordcloud_successful_install
Download wordcloud‑1.3.2‑cp36‑cp36m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
Copy the file to your current working directory
Open command prompt from Tools
Python -m pip install wordcloud-1.3.2-cp36-cp36m-win_amd64.whl
This will work:
1. create virEnv: conda create -n yourenvname python=3.5 anaconda
2. source activate yourenvname
3. conda install -c conda-forge wordcloud
Install wordcloud from the following page:
https://pypi.org/project/wordcloud/
Note: command: pip install wordcloud
Note: run the above command in Anaconda cmd prompt
Pre-requisities for instaling wordcloud is to install Visual C++(I got this error to install. So, you may give a try).This requires almost 4GB space. Once installed, restart your machine and then try the 1st step. It should be successful this time.
Ok. I solved my issue using wheels. Here are the steps:
Download the .whl file compatible with your Python version and your windows distribution (32bit or 64bit) from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
cd to the file path
Run this command python -m pip install

Installing OpenCPU on Amazon Linux instance

I have a an Amazon Linux instance which uses R to write a function to do some data analysis. I now want to call this function using a REST API. It seems that OpenCPU can get the job done for me.
I have found links to install OpenCPU on Ubuntu, but is there an easy to way to install it on Amazon Linux instance.
PS: I tried
sudo yum -y install opencpu
sudo yum -y install opencpu-server
It says no such package available.
I managed to get it installed from this script https://github.com/jeroenooms/opencpu-server/blob/master/rpm/buildscript.sh.
We now have rpm packages for CentOS 6 and 7 at https://archive.opencpu.org/

Rscript on ubuntu

Where can I install Rscript from? I need to run an R script from a php file using exec. However I need to install Rscript first.
The main package for R is called r-base. For the scripting and command-line front-end see littler (or r-cran-littler in xenial (16.04LTS) and beyond):
sudo apt-get install littler
Search the ubuntu repositories. Have you checked the littler package?
The answers posted so far are generally useful, but they don't directly answer the question. I recently had the same question and discovered there is no rscript binary for Ubuntu. The r binary itself is used to execute scripts in batch mode as opposed to the separate rscript binary that I was using in OS X.
It appears you may be able to get an rscript binary from other sources (see http://craig-russell.co.uk/2012/05/08/install-r-on-ubuntu.html#.UwKWzkJdW2Q for example), but I'm not sure why you would need that when simple running "r script.r" from the command line works just fine.
I tried running Rscript in a fresh ubuntu installation (16.04.2 LTS) and got:
The program 'Rscript' is currently not installed. You can install it by typing:
sudo apt install r-base-core
so, naturally, i ran sudo apt install r-base-core.
installation took a couple of minutes.
Later, i needed to install an R package, and realized i needed an R shell for that. running r returned:
The program 'r' is currently not installed. You can install it by typing:
sudo apt install r-cran-littler
Again, i followed, this time it was quite faster.
I don't know if these are the correct steps to take (or why they would be wrong), but it's what the system led me to do.

Resources