# Add Packages to Renku project via Conda - pyGIMLi

**URL:** <https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720>\
**Category:** General\
**Created:** [22 November 2022 19:00 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720 "2022-11-22T19:00:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [22 November 2022 19:00 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/1 "2022-11-22T19:00:06Z")

</div>

Hello,

I am trying to install the [pyGIMLi](https://www.pygimli.org/index.html) library in [a Renku project](https://renkulab.io/projects/champak.beeravolureddy/resibase-package-install-trial) which is a MnWE (Minimal not-Working Example) of my original problem.

I first tried installing **pyGIMLi** by modifying the `environment.yml` so that the CI/CD pipeline automatically initiates a Docker build upon pushing changes. After I failed I went over [several iterations](https://renkulab.io/gitlab/champak.beeravolureddy/resibase-package-install-trial/-/commits/master) of the `environment.yml` but didn’t succeed.

I also tried simply executing the following from the command line :

- `conda env update --file environment.yml --prune` according to [Add Packages to your Renku Project Environment](https://renku.readthedocs.io/en/latest/how-to-guides/general/install-packages.html?add-packages-to-your-renku-project-environment) and
- `conda create -n pg -c gimli -c conda-forge pygimli=1.3.0` following to the [pyGIMLi Installation docs](https://www.pygimli.org/installation.html).

None of the above worked for me. Thanks for any inputs.

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [23 November 2022 14:18 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/2 "2022-11-23T14:18:13Z")

</div>

Hi @champost - do you have an example of a conda `environment.yml` file that works on your local machine?

---

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [23 November 2022 21:15 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/3 "2022-11-23T21:15:15Z")

</div>

Hi @rrrrrok,

I did quite a bit of testing since posting my issue. My trials consisted of various build scenarios and making use of distinct Renku projects (all based on the Basic Python template).

I have come to the conclusion that it is the `defaults` channel specified in the default `environment.yml` file provided by the Basic Python template which is the source of the problem.

I am not sure whether I am running into some sort of [_channel collision_ issue](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html) here. In any case, I don’t understand the reason for specifying a `defaults` channel when all the packages listed in a Basic Python template either come from the `conda-forge` channel or via `pypi`.

- For starters, here is what the [`environment.yml`](https://github.com/SwissDataScienceCenter/renku-project-template/blob/master/python-minimal/environment.yml) file looks like in a Basic Python template

```auto
name: "base"
channels:
  - defaults
dependencies:
# - add packages here
# - one per line
prefix: "/opt/conda"

```

- Here is an example where the **build fails** (_e.g._ `ERROR: Job failed: execution took longer than 2h0m0s seconds` after increasing the [default build timeout](https://renku.discourse.group/t/build-time-exceeds-1h/698/2))

```auto
name: "base"
channels:
  - defaults
  - gimli
dependencies:
# - add packages here
# - one per line
  - pygimli=1.3.0
prefix: "/opt/conda"

```

- Here is an example where the **build succeeds**!

```auto
name: "base"
channels:
  - gimli
dependencies:
# - add packages here
# - one per line
  - pygimli=1.3.0
prefix: "/opt/conda"

```

Note that the whatever combination I tried, the removal of the `defaults` channel from the `environment.yml` file always resulted in a successful build.

Does the above make any sense to you ?

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [25 November 2022 13:57 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/4 "2022-11-25T13:57:03Z")

</div>

It only makes sense insofar as I know that conda can be fickle 🙂

I tried with this last option and it seems to build fine and works on renkulab afaict.

---

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [7 December 2022 17:17 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/5 "2022-12-07T17:17:08Z")

</div>

@rrrrrok

A follow-up on your offline suggestion to use [`mamba`](https://mamba.readthedocs.io/en/latest/index.html) instead of `conda` for a more efficient CI/CD build on Renkulab, I did try and it works like a charm !

For all others, `mamba` is already part of the default Python template. Output of `conda list | grep mamba` :

```auto
libmamba 0.23.1 hd8a31e3_1 conda-forge
libmambapy 0.23.1 py39hd55135b_1 conda-forge
mamba 0.23.1 py39hfa8f2c8_1 conda-forge

```

I transformed only the `conda env update` part in my `Dockerfile` into a `mamba env update` (keeping all other `conda`’s intact) and that was it :

```auto
RUN mamba env update -q -f /tmp/environment.yml && \
    /opt/conda/bin/pip install -r /tmp/requirements.txt && \
    conda clean -y --all && \
    conda env export -n "root"

```

---

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [11 July 2023 10:45 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/6 "2023-07-11T10:45:06Z")

</div>

@rrrrrok (and all those interested)

Since the [Renku Dockerfile now makes use of `mamba` instead of `conda`](https://github.com/SwissDataScienceCenter/renku-project-template/pull/154) for more efficient builds, note that the [Mamba documentation warns against](https://mamba.readthedocs.io/en/latest/user_guide/troubleshooting.html#mixing-the-defaults-and-conda-forge-channels) **mixing the Ananconda `defaults` channel and the popular `conda-forge` channels"**!

I am also beginning to wonder whether this incompatibility between the `defaults` and `conda-forge` channels extends to other channels as well (_e.g._ `gimli`, [see above](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/3)).

In any case, as the Ananconda `defaults` channel is proposed [by default in the Renku `environment.yml`](https://github.com/SwissDataScienceCenter/renku-project-template/blob/56aa0a25cc8d7c5133e2933e9fed10a87f95f5fd/python-minimal/environment.yml#L3), it may be useful to warn Renku users of incompatibility issues with a comment…

---

<div class="post-metadata">

**Author:** ![elisabetc](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/elisabetc/32/811_2.png) [@elisabetc](https://renku.discourse.group/u/elisabetc)\
**Post date:** [13 July 2023 08:35 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/7 "2023-07-13T08:35:28Z")

</div>

Thank you @champost for the additional details.

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [24 July 2023 15:42 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/8 "2023-07-24T15:42:20Z")

</div>

Hi @champost that’s a good point, thanks! I hesitate to disable the defaults channel completely, but a warning there seems reasonable. Extra points if you’re able to send a PR! 🙂

---

<div class="post-metadata">

**Author:** ![champost](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/champost/32/232_2.png) [@champost](https://renku.discourse.group/u/champost)\
**Post date:** [11 August 2023 12:19 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/9 "2023-08-11T12:19:43Z")

</div>

@rrrrrok : [Done](https://github.com/SwissDataScienceCenter/renku-project-template/pull/200) !

---

<div class="post-metadata">

**Author:** ![rrrrrok](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/rrrrrok/32/117_2.png) [@rrrrrok](https://renku.discourse.group/u/rrrrrok)\
**Post date:** [11 August 2023 12:49 UTC](https://renku.discourse.group/t/add-packages-to-renku-project-via-conda-pygimli/720/10 "2023-08-11T12:49:40Z")

</div>

Thanks @champost!! Merged, will be part of the next templates release
