IOError: [Errno 13] Permission denied: 'token.pickle'

未关闭
#172 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

The failure is in quickstart.py at the open('token.pickle', 'wb') call inside main(), reached after the OAuth browser flow completes. Check whether the script's working directory is writable, since the reporter installed packages with sudo and the file may be owned by root. The fix should either make the sample write the token somewhere it can write or document the directory requirement, and a run that saves token.pickle without the error shows it is done.

由索引模型根据 Issue 内容生成。

描述

Expected Behavior

to print either:
print('No data found.')
else:
print('Name, Major:')

Actual Behavior

Opening in existing browser session.
Traceback (most recent call last):
  File "quickstart.py", line 55, in <module>
    main()
  File "quickstart.py", line 35, in main
    with open('token.pickle', 'wb') as token:
IOError: [Errno 13] Permission denied: 'token.pickle'

Steps to Reproduce the Problem

Following quickstart.py example:
https://developers.google.com/sheets/api/quickstart/python#troubleshooting

  1. created a new google sheet and save file
  2. clicked enable the Google Sheet API set up with default setting: desktop app - downloaded .json file and stored in the same folder as the quickstart.py
  3. ran 'sudo pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib'
Found existing installation: google-auth-httplib2 0.0.3
    Uninstalling google-auth-httplib2-0.0.3:
      Successfully uninstalled google-auth-httplib2-0.0.3
  Found existing installation: google-api-python-client 1.7.9
    Uninstalling google-api-python-client-1.7.9:
      Successfully uninstalled google-api-python-client-1.7.9
  Found existing installation: google-auth-oauthlib 0.4.0
    Uninstalling google-auth-oauthlib-0.4.0:
      Successfully uninstalled google-auth-oauthlib-0.4.0
Successfully installed google-api-python-client-1.10.0 google-auth-httplib2-0.0.4 google-auth-oauthlib-0.4.1
  1. changed quickstart.py Sheet ID to match that of my sheet I had set up
  2. run 'python quickstart.py'
  3. pops up a window to authorise
  4. choose user and click authorise
  5. returned to screen and throws the error:
Traceback (most recent call last):
  File "quickstart.py", line 55, in <module>
    main()
  File "quickstart.py", line 35, in main
    with open('token.pickle', 'wb') as token:
IOError: [Errno 13] Permission denied: 'token.pickle'

Specifications

  • Python version (Python 2.7.16)
  • OS:
    PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
    NAME="Raspbian GNU/Linux"
    VERSION_ID="10"
    VERSION="10 (buster)"
    VERSION_CODENAME=buster
    ID=raspbian
    ID_LIKE=debian
主要语言
Python
星标
1.4k
派生
917
平均合并
3 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleworkspace/python-samples 的其他 Issue

查看 googleworkspace/python-samples 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。