QGrid widget not displaying in Binder

Hi there, I’m looking for some help please.

Problem

My Qgrid widget is not displaying in Binder, while it is displaying fine in my local Jupyter notebook environment.

Background

I have a repo that I want to run on Binder (binder link in README of repo). On my local system I run a conda environment with python 3.7 and the same packages installed as are listed in the requirements.txtfile. I use Qgrid and widgets to display and interact with a dataframe. This is a snapshot of the notebook running in my local environment:

These are the versions of notebook and qgrid packages on my local environment:

>>jupyter --version
jupyter core     : 4.6.1
jupyter-notebook : 6.0.2
qtconsole        : not installed
ipython          : 7.9.0
ipykernel        : 5.1.3
jupyter client   : 5.3.4
jupyter lab      : 1.2.3
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 4.4.0
traitlets        : 4.3.3
>>pip search qgrid
qgrid (1.1.1)  - An Interactive Grid for Sorting and Filtering DataFrames in Jupyter Notebook
  INSTALLED: 1.1.1 (latest)

Question

Any ideas about what could be the issue?

The combination of widgets and dependencies can require some testing of the options to get the right combination that works to build via MyBinder. One suggestion would be to convert your repo to better match the qgrid demo repo. Your current repo is using requirements.txt to install qgrid. That results in pip installing it. The demonstration repo for qgrid that runs on Binder uses conda for installation. (In fact, a commit message mentions that was done to handle enabling.) You may want to launch that repo and try to test some of your output generating code before you convert over yours. If the other installs seem to work with pip you can continue to use that for installation via the environment.yml by adding a pip sub-category. An example of doing that is here (with ‘official’ example here).

(For anyone who might benefit from this information later, I added the more general approach to enabling an extension in a follow-up below.)

1 Like

Thanks a lot for the time you took to look at this! Your suggestion makes sense. I switched to environment.yml from requirements.txt and now the qgrid widget renders perfectly. Thank you :smiley:

1 Like

I think the “enabling” thing is that to install a notebook extension you usually need to run a command to tell Jupyter that you want it enabled. Just installing the code isn’t enough. A pip package can’t execute commands as part of the install process. However a conda package can.

However I think I’ve started seeing notebook extensions distributed by pip package and they do “just work”. Am I just imagining that or has someone else seen that as well or knows if a pip package can do something like "run a command at the end of the install process’?

A notebook extension can enable itself by dropping a config file into the notebook config directory. pip supports this as a data file:

I don’t know if the same is possible for a lab extension.

2 Likes

I’m glad @betatim tagged this and the conversation continued because I picked up some more insight. It also was good that he tagged it because I was remiss in not expanding my answer earlier to include the standard approach for activating extensions in binderized repos. In my post above I meant to add as a ‘second suggestion’ that theoretically all that was necessary to make the qgird extension work from the state the repo was currently in at the time @Stephan_Heunis made the original post was two things:

  1. Add jupyter_contrib_nbextensions to requirements.txt
  2. Add jupyter contrib nbextension install --user to the postBuild file above the enabling command that was already there.

These steps are based on the example enabling Jupyter extensions repo among the Binder Examples. I was favoring the way the qgrid developers did things as the ‘first’ suggestion because I thought the path of least resistance was to follow their lead.

1 Like