Confliction between gspread and anvil-uplink

What I’m trying to do:
In a notebook backend, use gspread to read Google sheet. If I import the two libs together, I will get error ModuleNotFoundError: No module named 'google.oauth2’
What I’ve tried and what’s not working:
I cannot figure out the reason, I have to seperate them and use gspread in the beginning cell. And install and import anvil later at the ending cell in a notebook docker server.
Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

Clone link:
share a copy of your app

1 Like

I dont know if this helps but my use of gspread look like this:

import gspread
from oauth2client.service_account import ServiceAccountCredentials

and oauth2client is installed directly via pip

then credentials and a scope are created and used when connecting:

credentials = ServiceAccountCredentials.from_json_keyfile_dict(keyfile_dict, scope_list_of_urls)

client = gspread.authorize(credentials)

I’m almost sure the docs for gspread or docs for connecting to google sheets via api would give better insight though.

…I recognize that notebook :smiling_face_with_three_hearts:!

I love Deepnote, most of my backends is running on it.

1 Like

Hi,

Thanks for your reply. Your solution doesn’t work. But I found another way to get data from google sheet with pandas read_csv. Reference: Read Data from Google Sheets into Pandas without the Google Sheets API | by Merlin Schäfer | Towards Data Science

In this way, I don’t have to use gspread to read google sheet and no more conflictions.

1 Like