权限错误:权限被拒绝:'analyticsreporting.dat'

时间:2018-06-14 16:33:33

标签: google-analytics-api

我一直在尝试使用核心报告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'文件 有人有同样的问题吗?我很感激任何意见!

2 个答案:

答案 0 :(得分:0)

Python脚本确实对.dat文件具有权限,您可能需要在.dat文件上使用chmod或使用sudo运行脚本。

其他解决方案可能是将执行脚本的位置更改为系统用户可以访问的路径(尝试使用桌面)。

希望有帮助!

答案 1 :(得分:0)

It depends from how exactly you are executing you Python script.

In case you are not executing it directly from the same folder where your python script and analyticsreporting.dat files located - you need to specify also working directory.

See related topics:

SSIS Execute Process Task for Python script to API with OAuth2 - Access denied to the file with saved token

SSIS Execute Process Task Python script