【发布时间】:2019-03-06 19:44:51
【问题描述】:
我一直在尝试使用核心报告 API v4 访问谷歌分析数据,使用提供的 python 示例代码:
https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py
通过提示我给予许可的阶段后,
我收到以下错误消息:
Traceback (most recent call last):
File "Z:\PythonDocs\HelloAnalytics.py", line 85, in <module> main()
File "Z:\PythonDocs\HelloAnalytics.py", line 80, in main
analytics = initialize_analyticsreporting()
File "Z:\PythonDocs\HelloAnalytics.py", line 41, in
initialize_analyticsreporting
credentials = tools.run_flow(flow, storage, flags)
File "Z:\PythonDocs\oauth2client\_helpers.py", line 133, in
positional_wrapper
return wrapped(*args, **kwargs)
File "Z:\PythonDocs\oauth2client\tools.py", line 247, in run_flow
storage.put(credential)
File "Z:\PythonDocs\oauth2client\client.py", line 421, in put
self.locked_put(credentials)
File "Z:\PythonDocs\oauth2client\file.py", line 83, in locked_put
self._create_file_if_needed()
File "Z:\PythonDocs\oauth2client\file.py", line 70, in _create_file_if_needed
open(self._filename, 'a+b').close()
**PermissionError: [Errno 13] Permission denied:'analyticsreporting.dat'****
我检查了我的目录,文件“analyticsreporting.dat”就在那里。
有人有同样的问题吗?感谢您的意见!
【问题讨论】:
-
您是否尝试过删除 dat 文件并再次运行代码?
-
感谢您的建议。我试过了,还是一样的错误,“权限被拒绝”。
-
有趣。听起来python进程没有权限。可以修改文件的权限,让所有用户都可以读写吗?