Using Shiny server in an Anaconda R env

Good morning,

Is it possible to setup a Shiny server inside an Anaconda env?. I know you can very easily create web content from inside Anaconda with packages like r-shiny but… how then can I run a Shiny server which uses the R env with all the packages installed easily in Anaconda?.

Or does perhaps exist an easy way of moving that Anaconda created app to an independent server without having the issue of non being able to install in the server some kind of packages or R modules you easily installed in Anaconda?.

How the production deploy can be done easily if you cannot run a Shiny server inside an Anaconda env?. Anyone with experience in this kind of situation…

Any help would be very highly appreciated,
Best regards,

1 Like

Your question isn’t clear to me. You can run r-shiny code from within the version of R you install with Anaconda. If you are using a version of R that was not installed with Anaconda, you can use the ‘.libPaths()’ function in R to set the library path to the Anaconda location where libraries are installed, to use R libraries installed with Anaconda.

For example:
.libPaths("/Users/stephenweller/opt/anaconda3/envs/renv/lib/R/library")

I hope this answers your question.

1 Like

Basically the question was that, with Anaconda-navigator, you install extremely easy packages. But that packages and R version, are for Anaconda, and only Anaconda knows about the existence of that R version and packages for that R version installed in an Anaconda env.

If I use a Shiny server, this one, will try to find R packages and R itself, in /usr/local/bin and /usr/local/lib for instance. That, is not the path of the Anaconda env.

So how could I say to Shiny, to use the R binary and packages for that R binary located in the Anaconda env AND for the Anaconda env and avoid searching for them in standard paths. Perhaps better now? :slight_smile: (sorry if I’m not explaining properly :slight_smile: )

Cheers!

1 Like

R has environment variables that you can set:
R_HOME - point R to a specific home directory.
R_LIBS or R_LIBS_USER - specify a library directory where R packages are installed.

You can type 'help(“enironment variables”) inside R to get more information.

I believe you will want to set these for your Shiny server. If you use the ‘r-shiny’ library with the version of R that Anaconda installed however, you may not need to have a full server install of Shiny.

1 Like

Hi Sweller,

Thank you so much for your answer, really. I think I would not need a Shiny server for just viewing what r-shiny has helped me to generate. But if I wanted later to publish, I mean, to be available in a web format for being accesed or loaded from a let’s say Wordpress, wouldn’t I need a Shiny installed service in the machine where I generated the content (for publishing from the own machine where the code has been written)?.

The real problem is : The developers for which I’m getting this ready work with Anaconda navigator. They install in their Windows boxes packages from Conda with Navigator. Later, when they are going to publish the web app, the do copy the code to a server. That server, does not have Anaconda navigator… although I know it could have Conda.

What I was trying to achieve : I wanted the developers to upload the code (developed with Navigator in their workstations) to the servers, place where they would be able too to install Anaconda packages and then they to be able to have almost the same env in production env. Obviously, they develop web apps, for being able to be accessed from a web site that could be running any typical CMS.

So I though that, by installing an Ubuntu server, with Anaconda and Anaconda Navigator, and setting a Shiny server on it I should get almost the same env they have at their own computers. I think it’s the easiest way of having the most similar envs in devel (their desktop computers and production servers).

For all these, I was wondering how to use the Anaconda env with Shiny. I think that what you Seweller, pointed me could be OK for achieving my goal. Anyway, do you normally do, all these in a different manner?.

Cheers!

1 Like