Forums

Cannot find file in directory

I'm using the Google Calendar API which incorporates a json file named 'client_secret.json'. When trying to use the API i get an error saying:

oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'client_secret.json', 'No such file or directory', 2)

The JSON file is in the correct directory and works perfectly when I run my app on LocalHost, but not when I upload the files to pythonanywhere.

Try using an absolute file path: so /home/ilankessler/wherever

+1 to what @rcs1000 said -- that's almost certainly the correct solution.

@ilankessler

Maybe add something like this at the start of your prog to understand what the problem is?

import os
print("Current folder: " + os.getcwd())

(assuming Python 3).

More info in this help page re FileNotFoundException