Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python脚本没有';不能在Windows上工作(但可以在mac上工作)_Python_Python 2.7_Httplib2_Pygsheets - Fatal编程技术网

Python脚本没有';不能在Windows上工作(但可以在mac上工作)

Python脚本没有';不能在Windows上工作(但可以在mac上工作),python,python-2.7,httplib2,pygsheets,Python,Python 2.7,Httplib2,Pygsheets,我在mac上成功运行了完全相同的脚本,但在windows server 2012 r2上失败。我想知道什么是原因,我应该检查什么? 下面是一个脚本: import pygsheets gc = pygsheets.authorize(service_file='credentials.json') 我收到以下错误: Traceback (most recent call last): File "myscript.py", line 2, in <module> gc

我在mac上成功运行了完全相同的脚本,但在windows server 2012 r2上失败。我想知道什么是原因,我应该检查什么? 下面是一个脚本:

import pygsheets
gc = pygsheets.authorize(service_file='credentials.json')
我收到以下错误:

Traceback (most recent call last):
  File "myscript.py", line 2, in <module>
    gc = pygsheets.authorize(service_file='credentials.json')
  File "C:\ProgramData\Anaconda2\lib\site-packages\pygsheets\client.py", line 55
2, in authorize
    rclient = Client(oauth=credentials, **client_kwargs)
  File "C:\ProgramData\Anaconda2\lib\site-packages\pygsheets\client.py", line 79
, in __init__
    self._fetch_sheets()
  File "C:\ProgramData\Anaconda2\lib\site-packages\pygsheets\client.py", line 92
, in _fetch_sheets
    results = self._execute_request(None, request, False)
  File "C:\ProgramData\Anaconda2\lib\site-packages\pygsheets\client.py", line 41
8, in _execute_request
    response = request.execute()
  File "C:\ProgramData\Anaconda2\lib\site-packages\oauth2client\_helpers.py", li
ne 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\ProgramData\Anaconda2\lib\site-packages\googleapiclient\http.py", lin
e 835, in execute
    method=str(self.method), body=self.body, headers=self.headers)
  File "C:\ProgramData\Anaconda2\lib\site-packages\googleapiclient\http.py", lin
e 162, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "C:\ProgramData\Anaconda2\lib\site-packages\oauth2client\transport.py", l
ine 175, in new_request
    redirections, connection_type)
  File "C:\ProgramData\Anaconda2\lib\site-packages\oauth2client\transport.py", l
ine 282, in request
    connection_type=connection_type)
  File "C:\ProgramData\Anaconda2\lib\site-packages\httplib2\__init__.py", line 1
659, in request
    (response, content) = self._request(conn, authority, uri, request_uri, metho
d, body, headers, redirections, cachekey)
  File "C:\ProgramData\Anaconda2\lib\site-packages\httplib2\__init__.py", line 1
460, in _request
    _updateCache(headers, response, content, self.cache, cachekey)
  File "C:\ProgramData\Anaconda2\lib\site-packages\httplib2\__init__.py", line 4
74, in _updateCache
    cache.set(cachekey, text)
  File "C:\ProgramData\Anaconda2\lib\site-packages\httplib2\__init__.py", line 7
41, in set
    f = file(cacheFullPath, "wb")
IOError: [Errno 2] No such file or directory: 'c:\\users\\myusername\\appdata\\local\\t
emp\\1fda43ed-78ca-4316-b85c-51e7f359b3cb\\www.googleapis.com,drive,v3,files,inc
ludeTeamDriveItems=false&pageSize=500&fields=files%28id%2C+name%29&corpora=user&
supportsTeamDrives=false&q=mimeType%3D%27application%2Fvnd.google-apps.spreadshe
et%,5a24ad0f84d69be2396dd368422a2b6c'
我想知道这是否与windows上对c:\ProgramData的访问级别有关,如果是,我该如何解决这个问题?
我还更新了两台机器上的conda和pygsheets。

这是pygsheets中的一个已知错误,请从github安装以获得修复。或者,作为一种解决方法,您可以关闭缓存

import pygsheets
gc = pygsheets.authorize(service_file='credentials.json', no_cache=True)

您是否尝试在windows中以管理员身份运行脚本?无论
cacheFullPath
是什么,它显然填充了一些根本不是有效文件名的内容。
credentials.json中有什么内容?
import pygsheets
gc = pygsheets.authorize(service_file='credentials.json', no_cache=True)