我正在尝试将 Pydrive 连接到我的 Python 项目,但我得到了这个
Traceback (most recent call last):
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2client\clientsecrets.py", line 121, in _loadfile
with open(filename, 'r') as fp:
^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'client_secrets.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydrive\auth.py", line 386, in LoadClientConfigFile
client_type, client_info = clientsecrets.loadfile(client_config_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2client\clientsecrets.py", line 165, in loadfile
return _loadfile(filename)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2client\clientsecrets.py", line 124, in _loadfile
raise InvalidClientSecretsError('Error opening file', exc.filename,
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'client_secrets.json', 'No such file or directory', 2)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\LENOVO\OneDrive\Desktop\Computational Neuroscience\Data\Data Science.py", line 4, in <module>
gauth.LocalWebserverAuth(client_secrets='client_secrets.json')
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydrive\auth.py", line 113, in _decorated
self.GetFlow()
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydrive\auth.py", line 443, in GetFlow
self.LoadClientConfig()
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydrive\auth.py", line 366, in LoadClientConfig
self.LoadClientConfigFile()
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydrive\auth.py", line 388, in LoadClientConfigFile
raise InvalidConfigError('Invalid client secrets file %s' % error)
pydrive.settings.InvalidConfigError: Invalid client secrets file ('Error opening file', 'client_secrets.json', 'No such file or directory', 2)
那是我的代码
from pydrive.auth import GoogleAuth
gauth = GoogleAuth()
gauth.LocalWebserverAuth(client_secrets='client_secrets.json')
它说文件还没有在目录中,但我已经把它放在目录中了