adamerose / PandasGUI

A GUI for Pandas DataFrames
MIT No Attribution
3.19k stars 236 forks source link

Crash on import: TypeError: 'int' object is not subscriptable #131

Closed ioanpier closed 3 years ago

ioanpier commented 3 years ago

Describe the bug
When I try to run the example code on a Jupyter Notebook:

import pandas as pd
from pandasgui import show
df = pd.DataFrame(([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])
show(df)
I get the following error `TypeError: 'int' object is not subscriptable

Full stack trace of the error

TypeError                                 Traceback (most recent call last)

<ipython-input-15-c5c5d8976c89> in <module>()
      1 import pandas as pd
----> 2 from pandasgui import show
      3 df = pd.DataFrame(([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])
      4 show(df)

5 frames

/usr/local/lib/python3.7/dist-packages/pandasgui/__init__.py in <module>()
     13 
     14 # Imports
---> 15 from pandasgui.gui import show
     16 
     17 __all__ = ["show", "__version__"]

/usr/local/lib/python3.7/dist-packages/pandasgui/gui.py in <module>()
     13 from pandasgui.store import PandasGuiStore, PandasGuiDataFrameStore
     14 from pandasgui.utility import fix_ipython, fix_pyqt, as_dict, delete_datasets, resize_widget
---> 15 from pandasgui.widgets.dataframe_explorer import DataFrameExplorer
     16 from pandasgui.widgets.grapher import schemas
     17 from pandasgui.widgets.dragger import BooleanArg

/usr/local/lib/python3.7/dist-packages/pandasgui/widgets/dataframe_explorer.py in <module>()
      7 from pandasgui.utility import nunique
      8 from pandasgui.widgets.dataframe_viewer import DataFrameViewer
----> 9 from pandasgui.widgets.grapher import Grapher
     10 from pandasgui.widgets.reshaper import Reshaper
     11 from pandasgui.widgets.filter_viewer import FilterViewer

/usr/local/lib/python3.7/dist-packages/pandasgui/widgets/grapher.py in <module>()
     14 from pandasgui.store import PandasGuiStore, PandasGuiDataFrameStore, HistoryItem, SETTINGS_STORE
     15 
---> 16 from pandasgui.widgets.plotly_viewer import PlotlyViewer, plotly_markers
     17 from pandasgui.utility import flatten_df, flatten_iter, kwargs_string, nunique, unique, eval_title
     18 from pandasgui.widgets.dragger import Dragger, ColumnArg, Schema, BooleanArg

/usr/local/lib/python3.7/dist-packages/pandasgui/widgets/plotly_viewer.py in <module>()
     38 # Available symbol names for a given version of Plotly
     39 _extended_symbols = SymbolValidator().values[0::2][1::3]
---> 40 plotly_markers = [symbol for symbol in _extended_symbols if symbol[-3:] != "dot"]
     41 
     42 

/usr/local/lib/python3.7/dist-packages/pandasgui/widgets/plotly_viewer.py in <listcomp>(.0)
     38 # Available symbol names for a given version of Plotly
     39 _extended_symbols = SymbolValidator().values[0::2][1::3]
---> 40 plotly_markers = [symbol for symbol in _extended_symbols if symbol[-3:] != "dot"]
     41 
     42 

TypeError: 'int' object is not subscriptable

Environment OS: Unknown Python: eg. 3.7.10 IDE: Google Colab

Package versions
TO GET ALL RELEVANT PACKAGE VERSIONS, RUN THIS COMMAND IN BASH AND PASTE THE OUTPUT pip freeze | grep -i "pyqt|pandasgui|plotly|ipython|jupyter|notebook"

EXAMPLE OUTPUT

ipython==5.5.0
ipython-genutils==0.2.0
ipython-sql==0.3.9
jupyter==1.0.0
jupyter-client==5.3.5
jupyter-console==5.2.0
jupyter-core==4.7.1
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
notebook==5.3.1
pandasgui==0.2.10.1
plotly==4.4.1
PyQt5==5.15.4
PyQt5-Qt5==5.15.2
PyQt5-sip==12.8.1
PyQtWebEngine==5.15.4
PyQtWebEngine-Qt5==5.15.2
adamerose commented 3 years ago

Could you share a Google Colab notebook that produces this error? I'm surprised you even got past the PyQt imports, usually those fail on Google Colab because it has no GUI backend - I'd expect PandasGUI to not work at all on Colab.

Regarding the specific error message you have though, that line has been removed in recent commits so if you run pip install git+https://github.com/adamerose/pandasgui.git that should fix it

ioanpier commented 3 years ago

https://colab.research.google.com/drive/1IKUGk7KOyEChJ6pb_CdDMaqKIzkYGo24?usp=sharing

After installing the library again from the github link, I'm getting a new error ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py). If pandasgui cannot work on Colab, there should preferably an appropriate warning when trying to import it, otherwise perhaps mentioned in the installation guide.

Full stacktrace

---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

<ipython-input-1-c5c5d8976c89> in <module>()
      1 import pandas as pd
----> 2 from pandasgui import show
      3 df = pd.DataFrame(([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])
      4 show(df)

3 frames

/usr/local/lib/python3.7/dist-packages/pandasgui/__init__.py in <module>()
     13 
     14 # Imports
---> 15 from pandasgui.gui import show
     16 
     17 __all__ = ["show", "__version__"]

/usr/local/lib/python3.7/dist-packages/pandasgui/gui.py in <module>()
     13 from pandasgui.store import PandasGuiStore, PandasGuiDataFrameStore
     14 from pandasgui.utility import fix_ipython, fix_pyqt, as_dict, delete_datasets, resize_widget, get_figure_type
---> 15 from pandasgui.widgets.dataframe_explorer import DataFrameExplorer
     16 from pandasgui.widgets.grapher import schemas
     17 from pandasgui.widgets.func_ui import BooleanArg

/usr/local/lib/python3.7/dist-packages/pandasgui/widgets/dataframe_explorer.py in <module>()
      6 
      7 from pandasgui.utility import nunique
----> 8 from pandasgui.widgets.dataframe_viewer import DataFrameViewer
      9 from pandasgui.widgets.grapher import Grapher
     10 from pandasgui.widgets.reshaper import Reshaper

/usr/local/lib/python3.7/dist-packages/pandasgui/widgets/dataframe_viewer.py in <module>()
      7 from PyQt5 import QtCore, QtGui, QtWidgets
      8 from PyQt5.QtCore import Qt
----> 9 from typing import Literal
     10 from pandasgui.store import PandasGuiStore, PandasGuiDataFrameStore
     11 import pandasgui

ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------
adamerose commented 3 years ago

Most of these errors were actually related to some broken backwards compatibility with Python 3.7 not Colab specifically. I think I've fixed those all now, but like I said Colab is unsupported because it can't run PyQt5. If you install the latest dev version of PandasGUI you will see an error like below

WARNING | Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
WARNING | This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

If pandasgui cannot work on Colab, there should preferably an appropriate warning when trying to import it, otherwise perhaps mentioned in the installation guide.

Yeah the docs are still pretty incomplete, once I work on them I'll add a note about supported platforms.