AttributeError:“module”对象没有属性“authorize”

2024-09-19 20:28:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我想向谷歌电子表格报告一些事情,我的代码例如:

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'

谢谢你的反馈

问候 马林


Tags: 代码fromimportjsonws报告事情gc
1条回答
网友
1楼 · 发布于 2024-09-19 20:28:04

你的代码看起来没问题。为什么不重新安装gspread模块呢。在

您可以在一个文件夹中创建一个虚拟环境,并在其中安装所有必需的软件包。在

这可以帮助您在虚拟环境中运行所有项目,而不会影响其他模块或包。在

$pip安装virtualenv

$cd my_project_文件夹 $virtualenv my_项目

$cd我的项目 $source bin/激活

现在您可以安装所有模块和软件包了。在

http://docs.python-guide.org/en/latest/dev/virtualenvs/

相关问题 更多 >