Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
100 views
in Technique[技术] by (71.8m points)

python - How can i solve an authorization error for pygsheets?

i have spent the las few days trying to run this code:

import googlemaps
import pygsheets
API_key = 'XXX'#enter Google Maps API key
gc = pygsheets.authorize(service_file="/Users/Eliana/Desktop/Cash Flow dCaC-454d56c8c130[41].json")
sh = gc.open('Distancias para el cotizador')
sh2 = gc.open('Cotizador Versión INVERNADA')
wks = sh[4]
wks2 = sh2[2]
coordinates = wks.get_as_df(has_header = True, numerize=False, value_render= 'UNFORMATTED_VALUE', include_tailing_empty=False, include_tailing_empty_rows = False, start = 'A1')
coordinates = coordinates.drop(coordinates[coordinates.Coordenadas_1 == '#VALUE! (Function SPLIT parameter 1 value should be non-empty.)'].index)
coord_vendedor = wks2.get_values(start = 'I4', end = 'I4')
origins = coord_vendedor[0][0]
gmaps = googlemaps.Client(key=API_key)
column = "-35.575824,-58.01611"
dist = gmaps.distance_matrix(origins, column, mode='driving')["rows"][0]["elements"][0]["distance"]["value"]/1000

But the program keeps telling me there is an error:

AttributeError: module 'pygsheets' has no attribute 'authorize'

If you have any idea of how can i solve it please let me know

question from:https://stackoverflow.com/questions/65848948/how-can-i-solve-an-authorization-error-for-pygsheets

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...