# Using R packages (installed with conda)

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-r-packages-installed-with-conda%2F41937%3E%5C
**Category:** Spaces\
**Created:** [June 3, 2023, 4:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-r-packages-installed-with-conda%2F41937 "2023-06-03T04:16:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludvigolsen](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ludvigolsen/32/16528_2.png) [@ludvigolsen](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fludvigolsen)%5C
**Post date:** [June 3, 2023, 4:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-r-packages-installed-with-conda%2F41937%2F1 "2023-06-03T04:16:13Z")

</div>

My streamlit application runs a set of subprocess calls to R. Hence, I need to use conda to install some of the requirements. Is there a way to do this? Is a docker container the only approach, or can I have conda as a requirement and then use it to install the R packages?

---

<div class="post-metadata">

**Author:** ![ludvigolsen](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ludvigolsen/32/16528_2.png) [@ludvigolsen](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fludvigolsen)%5C
**Post date:** [June 3, 2023, 2:23pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-r-packages-installed-with-conda%2F41937%2F2 "2023-06-03T14:23:37Z")

</div>

I managed to create a docker solution. Here’s the docker script I ended up with:

```auto
FROM continuumio/miniconda3

WORKDIR /code

# Create the environment:
COPY ./environment.yml /code/environment.yml

RUN conda config --set channel_priority strict
RUN conda config --add channels conda-forge
RUN conda env create -f environment.yml

# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "plt_env", "/bin/bash", "-c"]

RUN pip install streamlit==1.22 Pillow lazyeval pandas

# Demonstrate the environment is activated:
RUN echo "Make sure streamlit is installed:"
RUN python -c "import streamlit; print('streamlit: ', streamlit. __version__ )"

COPY . .

# The code to run when container is started:

ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "plt_env", "streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"] 

```

Some of it is probably not required but it works.

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fradames)%5C
**Post date:** [June 6, 2023, 8:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-r-packages-installed-with-conda%2F41937%2F3 "2023-06-06T20:12:38Z")

</div>

great @ludvigolsen , thanks for sharing your solution here. I’d also link your running Space here

> **[Plot Confusion Matrix - a Hugging Face Space by ludvigolsen](https://huggingface.co/spaces/ludvigolsen/plot_confusion_matrix)**
>
> Discover amazing ML apps made by the community
