gsheets-connection icon indicating copy to clipboard operation
gsheets-connection copied to clipboard

import problem

Open Sheikh-Hamoodi opened this issue 2 years ago • 5 comments

Getting this issue while trying to import: from streamlit_gsheets.gsheets_connection import GSheetsConnection # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\123\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit_gsheets\gsheets_connection.py", line 39, in <module> from validators.utils import ValidationFailure ImportError: cannot import name 'ValidationFailure' from 'validators.utils' all the same code: import streamlit as st import streamlit_gsheets from streamlit_gsheets import GSheetsConnection

url = "https://docs.google.com/spreadsheets/d/1JDy9md2VZPz4JbYtRPJLs81_3jUK47nx6GYQjgU8qNY/edit?usp=sharing"

conn = st.experimental_connection("gsheets", type=GSheetsConnection)

data = conn.read(spreadsheet=url, usecols=[0, 1]) st.dataframe(data) `

Sheikh-Hamoodi avatar Sep 05 '23 23:09 Sheikh-Hamoodi

Thanks, @Sheikh-Hamoodi for pointing this out! 🙂

I'm facing the same error when trying to connect Google Sheets in both ways, i.e., via public URL and private account 👇 public_gsheets_error

Please guide us on this, @sfc-gh-jcarroll 🙏

ShruAgarwal avatar Sep 07 '23 11:09 ShruAgarwal

It looks like a breaking change in a recent version 0.21.2 of validators https://github.com/python-validators/validators/pull/283 (see also https://github.com/python-validators/validators/pull/291)

Should be able to work around if you pin validators to an earlier version like 0.21.0

@sfc-gh-tszerszen would you be able to make a fix when you get a chance? I'm happy to review. If we want to just update the minimum version of validators and make the change to new error, that's fine with me.

sfc-gh-jcarroll avatar Sep 07 '23 19:09 sfc-gh-jcarroll

Thanks a lot for the suggestion @sfc-gh-jcarroll 🤗 I pinned validators==0.21.1 and it works great!

ShruAgarwal avatar Sep 08 '23 13:09 ShruAgarwal

Hey, I tried to pin the validators but still it gave me the error. I tried 0.21.1 and 0.21.0

The error says: TypeError: ValidationFailure.__init__() got an unexpected keyword argument 'args' Traceback: File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script exec(code, module.__dict__) File "/Users/is/Desktop/Medium/data-prep/eu.py", line 51, in <module> email, database = create_database() File "/Users/is/Desktop/Medium/data-prep/ue.py", line 10, in create_database database = conn.read( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/streamlit_gsheets/gsheets_connection.py", line 570, in read return self.client.read( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/streamlit_gsheets/gsheets_connection.py", line 423, in read url = self._get_download_as_csv_url( File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/streamlit_gsheets/gsheets_connection.py", line 370, in _get_download_as_csv_url validation_failure = ValidationFailure(

Any suggestion? @sfc-gh-jcarroll

im-sanka avatar Sep 19 '23 09:09 im-sanka

@Sheikh-Hamoodi @ShruAgarwal @im-sanka @sfc-gh-jcarroll thank you for taking a look and this feedback I'll take a look, probably during next weekend and will get back to you

sfc-gh-tszerszen avatar Sep 19 '23 16:09 sfc-gh-tszerszen