qgrid icon indicating copy to clipboard operation
qgrid copied to clipboard

qgrid does not display in Jupyter notebook

Open mowilk opened this issue 5 years ago • 9 comments

Environment

  • Operating System: JupyterHub
  • Python Version: $ python --version: Python 3.6.7
  • How did you install Qgrid: (pip, conda, or other (please explain)) pip install qgrid
  • Python packages: $ pip freeze or $ conda list (please include qgrid, notebook, and jupyterlab versions)
    • qgrid==1.1.1
    • notebook==5.7.8
    • pandas==0.23.4
    • ipywidgets==7.2.1
    • jupyterlab==0.35.4
    • jupyterlab-server==0.2.0
  • Jupyter lab packages (if applicable): $ jupyter labextension list
    • @jupyter-widgets/jupyterlab-manager v0.38.1 enabled OK
    • @jupyterlab/geojson-extension v0.18.1 enabled OK
    • @jupyterlab/hub-extension v0.12.0 enabled OK
    • @jupyterlab/plotly-extension v0.18.2 enabled OK
    • jupyter-gmaps v0.8.0 enabled OK
    • jupyter-matplotlib v0.3.0 enabled OK

Description of Issue

  • What did you expect to happen?
    • grid display
  • What happened instead?
    • no output

Reproduction Steps

>>> df = pd.DataFrame({"a": [1, 2, 3, 4], "b": [5, 6, 7, 8]})
>>> grid = qgrid.show_grid(df)
>>> grid

What steps have you taken to resolve this already?

  • also tried running qgrid.show_grid() with show_toolbar = True as in the demo notebooks
  • tried running qgrid.nbinstall(overwrite=True) at beginning of notebook, but got an error saying there was no nbinstall attribute
  • tried running from IPython.display import display at beginning of notebook and using display(qgrid) to display df

Anything else?

mowilk avatar Jun 06 '19 22:06 mowilk

Read somewhere that there could be compatibility issues between ipywidget, notebook, and/or jupyterlab, so I also installed the versions of those packages used in the demo notebook using

import sys
!{sys.executable} -m pip install notebook==5.7.6 -q
!{sys.executable} -m pip install jupyterlab==0.35.4 -q
!{sys.executable} -m pip install ipywidgets==7.4.2 -q
!{sys.executable} -m pip install qgrid==1.1.1 -q

Still no success.

mowilk avatar Jun 08 '19 16:06 mowilk

+1 experiencing the same issue with the same setup

dsal1951 avatar Jun 09 '19 16:06 dsal1951

@mowilk FWIW, I solved this by installing ipywidgets and qgrid into a fresh Python 3.x environment and then running jupyter nbextension enable --py widgetsnbextension I could have sworn I had already done this on my previous environment, but for whatever reason it worked with a fresh one

dsal1951 avatar Jun 10 '19 06:06 dsal1951

Ran the following commands, shut down my notebook server. Starting again, and it began working. jupyter nbextension enable --py --sys-prefix qgrid jupyter nbextension enable --py --sys-prefix widgetsnbextension

MillHaus33 avatar Jun 17 '19 22:06 MillHaus33

I have experienced the same problem (qgrid=1.3.1). Found that uninstalling and then re-installing qgrid=1.3.0 via pip and then running jupyter nbextension enable --py --sys-prefix qgrid fixed the issue

naveace avatar Nov 22 '20 19:11 naveace

Ran the following commands, shut down my notebook server. Starting again, and it began working. jupyter nbextension enable --py --sys-prefix qgrid jupyter nbextension enable --py --sys-prefix widgetsnbextension

Restarting the notebook did the trick. Not just the kernel, but the whole lab instance. file ->hub control panel -> stop -> start

robkers1993 avatar Jan 08 '21 14:01 robkers1993

Ran the following commands, shut down my notebook server. Starting again, and it began working. jupyter nbextension enable --py --sys-prefix qgrid jupyter nbextension enable --py --sys-prefix widgetsnbextension

This works! try enabling both extensions using the above commands. Then shutdown jupyter and start it all fresh.

Use qgrid.enable() command to automatically render all DataFrames and Series as qgrids.

Other options which you can try are: qgrid.set_grid_option('maxVisibleRows', 50) qgrid.set_grid_option('forceFitColumns', False) qgrid.set_grid_option('defaultColumnWidth', 200)

import pandas as pd
import numpy as np
import qgrid
randn = np.random.randn

# Get a pandas DataFrame containing the daily prices for the S&P 500 from 1/1/2014 - 1/1/2017
from pandas_datareader.data import DataReader
spy = DataReader(
    'SPY',
    'yahoo',
    pd.Timestamp('2014-01-01'),  
    pd.Timestamp('2017-01-01'),
)
# Tell qgrid to automatically render all DataFrames and Series as qgrids.
**qgrid.enable()**

# Render the DataFrame as a qgrid automatically
spy

reference: https://github.com/quantopian/qgrid-notebooks/blob/master/index.ipynb

Subhanimuhammed avatar Feb 03 '21 08:02 Subhanimuhammed

@mowilk FWIW, I solved this by installing ipywidgets and qgrid into a fresh Python 3.x environment and then running jupyter nbextension enable --py widgetsnbextension I could have sworn I had already done this on my previous environment, but for whatever reason it worked with a fresh one

I experience this problem from time to time user to modify grid.py and then it works.

Today problem arises again, and your command works for me. Thanks!

jitvimol avatar Apr 13 '21 17:04 jitvimol

Ran the following commands, shut down my notebook server. Starting again, and it began working. jupyter nbextension enable --py --sys-prefix qgrid jupyter nbextension enable --py --sys-prefix widgetsnbextension

This worked for me! Thank you!

Rofromthetrap avatar Oct 09 '21 18:10 Rofromthetrap