Ask coding questions

← Back to all posts
Importing json
SteeveDOMINIQUE (1)

I'm trying to import a json file which contains a key to access a specific Google Cloud Storage to create a bucket using the following:

import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="key.json"

From my Pycharm IDE the code works perfectly but running my code in repl.it I keep getting:

Conflict: 409 POST https://www.googleapis.com/storage/v1/b?project=<PROJECT_NAME>: Sorry, that name is not available. Please try a different one.

I'm assuming the file (key.json) wasn't properly loaded which is why I getting this error. Is there a way to bypass this issue in repl.it

Thanks in advance

Comments
hotnewtop
SteeveDOMINIQUE (1)

I was able to get it to work by providing the full file path like:

"/home/runner/key.json"

SteeveDOMINIQUE (1)

corrected my import like

import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="key.json"

but still getting the same error