PAIR-code / what-if-tool

Source code/webpage/demos for the What-If Tool
https://pair-code.github.io/what-if-tool
Apache License 2.0
923 stars 170 forks source link

module 'pyparsing' has no attribute 'downcaseTokens' #185

Open paulaceccon opened 3 years ago

paulaceccon commented 3 years ago

IInstall:

!pip install pyparsing==2.4.7
!pip install --upgrade witwidget -q
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_7815/70839168.py in <module>
      1 #@title Invoke What-If Tool for the data and model {display-mode: "form"}
----> 2 from witwidget.notebook.visualization import WitWidget, WitConfigBuilder
      3 
      4 num_datapoints = 5000  #@param {type: "number"}
      5 tool_height_in_px = 700  #@param {type: "number"}

/usr/local/lib/python3.9/dist-packages/witwidget/notebook/visualization.py in <module>
     25   from witwidget.notebook.colab.wit import *  # pylint: disable=wildcard-import,g-import-not-at-top
     26 else:
---> 27   from witwidget.notebook.jupyter.wit import *  # pylint: disable=wildcard-import,g-import-not-at-top
     28 
     29 

/usr/local/lib/python3.9/dist-packages/witwidget/notebook/jupyter/wit.py in <module>
     24 from traitlets import Unicode
     25 from traitlets import Set
---> 26 from witwidget.notebook import base
     27 
     28 

/usr/local/lib/python3.9/dist-packages/witwidget/notebook/base.py in <module>
     15 import base64
     16 import json
---> 17 import googleapiclient.discovery
     18 import os
     19 import logging

/usr/local/lib/python3.9/dist-packages/googleapiclient/discovery.py in <module>
     40 
     41 # Third-party imports
---> 42 import httplib2
     43 import uritemplate
     44 import google.api_core.client_options

/usr/local/lib/python3.9/dist-packages/httplib2/__init__.py in <module>
     50     # idea is to have soft-dependency on any compatible module called socks
     51     from . import socks
---> 52 from . import auth
     53 from .error import *
     54 from .iri2uri import iri2uri

/usr/local/lib/python3.9/dist-packages/httplib2/auth.py in <module>
     18 
     19 quoted_string = pp.dblQuotedString.copy().setName("quoted-string").setParseAction(unquote)
---> 20 auth_param_name = token.copy().setName("auth-param-name").addParseAction(pp.downcaseTokens)
     21 auth_param = auth_param_name + pp.Suppress("=") + (quoted_string | token)
     22 params = pp.Dict(pp.delimitedList(pp.Group(auth_param)))

AttributeError: module 'pyparsing' has no attribute 'downcaseTokens'
jameswex commented 3 years ago

Thanks for the report. I'm wondering if when you do "pip list" if pyparsing version is not 2.4.7 but 3.x. If you are really using 2.4.7 then I wouldn't expect this error.

paulaceccon commented 3 years ago

This the output:

Package                           Version
--------------------------------- ---------------
absl-py                           0.15.0
argon2-cffi                       21.1.0
astunparse                        1.6.3
attrs                             21.2.0
Augmentor                         0.2.8
backcall                          0.2.0
bleach                            4.1.0
cachetools                        4.2.4
certifi                           2021.10.8
cffi                              1.15.0
charset-normalizer                2.0.7
clang                             5.0
cloudpickle                       2.0.0
coloredlogs                       15.0.1
coverage                          5.5
cycler                            0.10.0
dask                              2021.10.0
debugpy                           1.5.1
decorator                         5.1.0
defusedxml                        0.7.1
docopt                            0.6.2
entrypoints                       0.3
flatbuffers                       1.12
fsspec                            2021.10.1
future                            0.18.2
gast                              0.4.0
google-api-core                   2.2.0
google-api-python-client          2.28.0
google-auth                       2.3.1
google-auth-httplib2              0.1.0
google-auth-oauthlib              0.4.6
google-pasta                      0.2.0
googleapis-common-protos          1.53.0
grpcio                            1.41.1
h5py                              3.1.0
httplib2                          0.20.1
humanfriendly                     10.0
idna                              3.3
ipykernel                         6.4.2
ipython                           7.28.0
ipython-genutils                  0.2.0
ipywidgets                        7.6.5
jedi                              0.18.0
Jinja2                            3.0.2
joblib                            1.1.0
jsonschema                        4.1.2
jupyter-client                    7.0.6
jupyter-contrib-core              0.3.3
jupyter-contrib-nbextensions      0.5.1
jupyter-core                      4.8.1
jupyter-highlight-selected-word   0.2.0
jupyter-latex-envs                1.4.6
jupyter-nbextensions-configurator 0.4.1
jupyterlab-pygments               0.1.2
jupyterlab-widgets                1.0.2
keras                             2.6.0
Keras-Preprocessing               1.1.2
kiwisolver                        1.3.2
locket                            0.2.1
lxml                              4.6.3
Markdown                          3.3.4
MarkupSafe                        2.0.1
matplotlib                        3.4.3
matplotlib-inline                 0.1.3
mistune                           0.8.4
nbclient                          0.5.4
nbconvert                         6.2.0
nbformat                          5.1.3
nest-asyncio                      1.5.1
nose                              1.3.7
notebook                          6.4.5
numpy                             1.19.5
oauth2client                      4.1.3
oauthlib                          3.1.1
opt-einsum                        3.3.0
packaging                         21.0
pandas                            1.3.3
pandocfilters                     1.5.0
parso                             0.8.2
partd                             1.2.0
pexpect                           4.8.0
pickleshare                       0.7.5
Pillow                            8.3.1
pip                               21.3.1
pipreqs                           0.4.11
prometheus-client                 0.11.0
prompt-toolkit                    3.0.21
protobuf                          3.19.0
psutil                            5.8.0
ptyprocess                        0.7.0
pyasn1                            0.4.8
pyasn1-modules                    0.2.8
pycparser                         2.20
Pygments                          2.10.0
PyGObject                         3.26.1
pyparsing                         2.4.7
pyrsistent                        0.18.0
python-apt                        1.6.5+ubuntu0.7
python-dateutil                   2.8.2
pytz                              2021.3
PyYAML                            6.0
pyzmq                             22.3.0
requests                          2.26.0
requests-oauthlib                 1.3.0
rsa                               4.7.2
scikit-learn                      1.0
scipy                             1.7.1
seaborn                           0.11.2
Send2Trash                        1.8.0
setuptools                        58.3.0
six                               1.15.0
swifter                           1.0.9
tensorboard                       2.7.0
tensorboard-data-server           0.6.1
tensorboard-plugin-wit            1.8.0
tensorflow                        2.6.0
tensorflow-addons                 0.14.0
tensorflow-estimator              2.6.0
termcolor                         1.1.0
terminado                         0.12.1
testpath                          0.5.0
threadpoolctl                     3.0.0
toolz                             0.11.1
tornado                           6.1
tqdm                              4.62.3
traitlets                         5.1.1
typeguard                         2.13.0
typing-extensions                 3.7.4.3
uritemplate                       4.1.1
urllib3                           1.26.7
wcwidth                           0.2.5
webencodings                      0.5.1
Werkzeug                          2.0.2
wheel                             0.37.0
widgetsnbextension                3.5.1
witwidget                         1.8.1
wrapt                             1.12.1
yarg                              0.1.9

And the error is the same.

jameswex commented 3 years ago

What is the notebook environment you are seeing this failure in? Does restarting the kernel help?

paulaceccon commented 3 years ago

Not sure what you mean but I'm using jupyter notebook, with Python 3.9. And no, restarting it doesn't help. Thanks for the quick responses!

jameswex commented 3 years ago

Are you able to test with python 3.6 or 3.7? I haven't tried WIT in py 3.9 yet.

queengooborg commented 2 years ago

Came here after running into the same issue but in web2py. This issue seems to come from an incompatibility in httplib2. After upgrading to v0.20.2 of httplib2, I am no longer running into this problem.

Hope this helps!

hkhdair commented 2 years ago

Came here after running into the same issue but in web2py. This issue seems to come from an incompatibility in httplib2. After upgrading to v0.20.2 of httplib2, I am no longer running into this problem.

Hope this helps!

Thanks. That really helped 👍

amitpandey2194 commented 2 years ago

Came here after running into the same issue but in web2py. This issue seems to come from an incompatibility in httplib2. After upgrading to v0.20.2 of httplib2, I am no longer running into this problem.

Hope this helps!

Or by downgrading to 0.19.0. That also worked

alishaneogi98 commented 2 years ago

Thanks This also work for me. By running this command only - pip install httplib2. This will automatically downgrade the pyparsing to 2.4.7 version.

pip install httplib2

Requirement already satisfied: httplib2 in c:\programdata\anaconda3\lib\site-packages (0.20.1) Collecting pyparsing<3,>=2.4.2 Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB) Installing collected packages: pyparsing Attempting uninstall: pyparsing Found existing installation: pyparsing 3.0.4 Uninstalling pyparsing-3.0.4: Successfully uninstalled pyparsing-3.0.4 Successfully installed pyparsing-2.4.7 Note: you may need to restart the kernel to use updated packages.