Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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
FileNotFoundError使用Python';指向错误的驱动器号;s df2gspread_Python_Python 3.x_Powershell_Oauth 2.0 - Fatal编程技术网

FileNotFoundError使用Python';指向错误的驱动器号;s df2gspread

FileNotFoundError使用Python';指向错误的驱动器号;s df2gspread,python,python-3.x,powershell,oauth-2.0,Python,Python 3.x,Powershell,Oauth 2.0,我尝试运行的代码非常简单,尝试使用df2gspread包将Pandas数据帧发送到GoogleSheets from df2gspread import df2gspread as d2g import pandas as pd df = live_data() spreadsheet = 'my_spreadsheet_key' wks_name = 'my_sheet_name' d2g.upload(df, spreadsheet, wks_name) 当我从PowerShell运行该

我尝试运行的代码非常简单,尝试使用df2gspread包将Pandas数据帧发送到GoogleSheets

from df2gspread import df2gspread as d2g
import pandas as pd

df = live_data()
spreadsheet = 'my_spreadsheet_key'
wks_name = 'my_sheet_name'
d2g.upload(df, spreadsheet, wks_name)
当我从PowerShell运行该基本脚本时,会收到以下错误消息

C:\users\USER\github> python script_Folder\my_script.py
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\oauth2client\clientsecrets.py", line 122, in _loadfile
    with open(filename, 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'O:\\/.gdrive_private'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "script_Folder\my_script.py", line 177, in <module>
    d2g.upload(df_liveTiming, spreadsheet, wks_name)
  File "C:\Anaconda3\lib\site-packages\df2gspread\df2gspread.py", line 76, in upload
    credentials = get_credentials(credentials)
  File "C:\Anaconda3\lib\site-packages\df2gspread\utils.py", line 77, in get_credentials
    client_secret_file, SCOPES)
  File "C:\Anaconda3\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\oauth2client\client.py", line 2105, in flow_from_clientsecrets
    cache=cache)
  File "C:\Anaconda3\lib\site-packages\oauth2client\clientsecrets.py", line 166, in loadfile
    return _loadfile(filename)
  File "C:\Anaconda3\lib\site-packages\oauth2client\clientsecrets.py", line 126, in _loadfile
    exc.strerror, exc.errno)
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'O:\\/.gdrive_private', 'No such file or directory', 2)
C:\users\USER\github>python脚本\u文件夹\my\u script.py
回溯(最近一次呼叫最后一次):
文件“C:\Anaconda3\lib\site packages\oauth2client\clientsecrets.py”,第122行,在加载文件中
以fp形式打开(文件名为“r”):
FileNotFoundError:[Errno 2]没有这样的文件或目录:“O:\\/.gdrive\u private”
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“script\u Folder\my\u script.py”,第177行,在
d2g.上传(df_实时计时、电子表格、wks_名称)
上传文件“C:\Anaconda3\lib\site packages\df2gstrip\df2gstrip.py”,第76行
凭证=获取凭证(凭证)
get\U凭证中的文件“C:\Anaconda3\lib\site packages\df2gspread\utils.py”,第77行
客户端(机密文件,作用域)
文件“C:\Anaconda3\lib\site packages\oauth2client\util.py”,第137行,在位置包装中
已包装退货(*args,**kwargs)
文件“C:\Anaconda3\lib\site packages\oauth2client\client.py”,第2105行,在\u clientsecrets的flow\u中
缓存=缓存)
文件“C:\Anaconda3\lib\site packages\oauth2client\clientsecrets.py”,第166行,在loadfile中
返回\u加载文件(文件名)
文件“C:\Anaconda3\lib\site packages\oauth2client\clientsecrets.py”,第126行,在加载文件中
exc.strerror,exc.errno)
oauth2client.clientsecrets.InvalidClientSecretError:(“打开文件时出错”,“O:\\/.gdrive\u private”,“无此类文件或目录”,2)
O:\驱动器是我工作时使用的网络驱动器,我不知道它是如何突然插入到这个脚本中的。.gdrive_私有文件夹位于我的主目录中,如中所示


我试图调查系统变量,以确保没有什么不合适的地方,但我没有看到任何东西。我试着浏览它在错误消息中列出的脚本,但我想不出来。有人能帮我弄清楚这里发生了什么吗?

我猜O:\是您的“真实”主目录,而该脚本在那里非常失败,因为它需要POSIX系统;毕竟它还有
/
,这是POSIX目录分隔符。在代码的开头放一个
导入os
os.getcwd()
,然后请发布输出。我用os.getcwd()命令运行它,它说它当前的工作目录是C:\users\USER\github\script\u文件夹\