Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modifying kernelspec used at launch

See original GitHub issue

I’m working on setting up a Jupyter notebook that uses the R kernel (IRkernel) inside a conda environment named contrib-viz. When I launch the binder, the kernel is not found, as seen in the following screenshot kernel_error

The problem seems to be that the local notebook is saved with a kernlespec that includes the name of the conda environment:

"kernelspec": { 
   "display_name": "R [conda env:contrib-viz]", 
   "language": "R", 
   "name": "conda-env-contrib-viz-r" 

Jupyter launched through binder is trying to use a different kernelspec:

"kernelspec": {
   "display_name": "R [conda env:conda]",
   "language": "R",
   "name": "conda-env-conda-r"

Selecting the kernel R [conda env:conda] that is offered in the drop down menu in the screenshot is a workaround, but I expect that will deter novice users who would most benefit from the binder. I can also edit the .ipynb file to make the kernelspec match what binder expects, but then I get the kernel not found error when I run the notebook in my local environment. Renaming my conda environment would probably work, but I have multiple environments for this project and prefer to keep them distinct if possible. Is there a better general solution?

The binder link is This is a temporary branch for a pull request that will be deleted soon. Currently, this is the version with an edited .ipynb file that works in binder but not locally.

Thanks for the binder service. I see a lot of opportunities to use this.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

agittercommented, Mar 5, 2019

This is working now so I’ll leave some final notes for anyone who has a similar problem. I decided that modifying the .ipynb notebook file in the postBuild script was the best way to accomplish what I wanted. I can still use nb_conda_kernels in my local environment. The modified notebook has an edited kernelspec to match a kernel that is available in Binder.

I was unable to get conda create --name new_name --clone old_name working. I received the error

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.

even after briefly attempting to enable conda in postBuild. Because conda clean -tipsy has already run before the conda create in the postBuild script, creating the environment is slow anyway. conda has to re-download all of the packages again.

Part of my initial confusion was already related to this issue I had assumed that using Binder with an environment.yml file would work similarly to

conda env create --file environment.yml
conda activate <new_environment>

After looking through the repo2docker conda buildpack code I realized that the environment in environment.yml is not created or activated. It is used to update the base conda environment. That could be documented in and I’m happy to suggest something in another issue.

betatimcommented, Mar 5, 2019

The environment.yml is used to update the environment so even for packages that are installed by default the version specified in the repositories environment.yml should “win”. Otherwise please report a bug in

The best we have to offer right now for running things locally is which is the tool that Binder uses to build your environment. You can install it with pip install jupyter-repo2docker and run repo2docker to get the same experience as on (with some patience to build the image). For actual local development repo2docker --editable some/local/dir is more useful as it will mount your local directory read-write into the container so you can keep using your favourite editor and tools. Polishing the run-locally-for-day-to-day-dev experience is something we are working on and welcome contributions. IN particular in making things faster.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modifying kernelspec used at launch · Issue #152 - GitHub
I'm working on setting up a Jupyter notebook that uses the R kernel (IRkernel) inside a conda environment named contrib-viz. When I launch...
Read more >
Making kernels for Jupyter — jupyter_client 7.4.8 documentation
At kernel startup, Jupyter passes the kernel a connection file. ... Currently, no other files are used, but this may change in the...
Read more >
Jupyter Notebook Kernels: How to Add, Change, Remove
Change Kernel name. 1) Use $ jupyter kernelspec list to see the folder the kernel is located in. 2) In that folder, open...
Read more >
Changing Jupyter kernelspec to point to anaconda python
For personal sanity and organization, I want the version of Python that I use in the command line to be the same that...
Read more >
Parameterized Kernelspecs - HackMD
Kernelspecs are the means by which applications that use Jupyter kernels can ... The most common clients to launch kernels are the Jupyter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found