Binder image is picking up R packages but not Python

Hi all, I have this repo where I want to build images for both R and Python with Binder. The R packages are working fine from the install.r file, but I am not able to load the Python packages as defined in requirements.txt. Any ideas? Thanks so much.

Yes, this is because everything is getting overridden by your Dockerfile as pointed out in the documentation here.

“If a Dockerfile is present, all other configuration files will be ignored.”

You Dockerfile happens to have commands to use the install.R file, and so those libraries are getting installed.

A few options:

  1. It is suggested for Binder is to avoid using Dockerfiles and to use the supported configuration files. If the current Dockerfile needed to be in root, you could leave it there and make a directory named binder and put the install.R and requirements.txt for binder in that. Use of a directory other than root is covered here.
    However, it looks like your Dockerfile is simply for dealing with Binder. The recommended R examples are here and here.

  2. The one with conda actually looks like it would solve most of your issues with a single configuration file, if you want to replace Dockerfile and requirements.txt in your root. Or you could put it in a binder directory without touching the current state of root. Conda is capable of installing many Python packages and so you probably could list most packages on the main list; however, since you are using requirements.txt presently, I’ll point out that an example using pip inside the environment.yml file is discussed in this recent post. That example just has one item that would get installed with pip but you can add more to the list the way the single one currently is indented.

  3. Assuming you know how to make Dockerfiles and use pip with a file (so this would be the advanced way), the non-recommended way would be to add the command to your Dockerfile to run the pip install command, directing it you use your requirements.txt. The drawback to this way is that it is not recommended and so changes in the binder system are more likely to lead to builds breaking in the future than if you use the suggested configuration files.

1 Like

Wow, thanks so much for steering me in the right direction. I like the idea of using Conda.

1 Like