AttributeError: 'module' object has no attribute 'authorize'
AttributeError: 'module' object has no attribute 'authorize'
我想向 google 电子表格报告一些内容,例如我的代码:
import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('con.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open("temperatura")
ws = wks.get_worksheet(0)
ws.update_acell('A1','IT WORKS!')
我收到错误:
gc = gspread.authorize(credentials) AttributeError: 'module' object
has no attribute 'authorize'
感谢反馈
问候
马林
你的代码看起来没问题。为什么不尝试再次安装 gspread 模块。
您可以在文件夹中创建一个虚拟环境,并在那里安装所有必需的包。
这可能会帮助您 运行 虚拟环境中的所有项目,而不会影响其他模块或包。
$pip 安装 virtualenv
$光盘my_project_folder
$ virtualenv my_project
$cd my_project
$来源bin/activate
现在您可以安装所有模块和包了。
我想向 google 电子表格报告一些内容,例如我的代码:
import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('con.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open("temperatura")
ws = wks.get_worksheet(0)
ws.update_acell('A1','IT WORKS!')
我收到错误:
gc = gspread.authorize(credentials) AttributeError: 'module' object has no attribute 'authorize'
感谢反馈
问候 马林
你的代码看起来没问题。为什么不尝试再次安装 gspread 模块。
您可以在文件夹中创建一个虚拟环境,并在那里安装所有必需的包。
这可能会帮助您 运行 虚拟环境中的所有项目,而不会影响其他模块或包。
$pip 安装 virtualenv
$光盘my_project_folder $ virtualenv my_project
$cd my_project $来源bin/activate
现在您可以安装所有模块和包了。