Jack Hanson
Jack Hanson

Reputation: 321

Cannot set PATH variable for Google BigQuery in Python - unicode error

This is my first time using BigQuery (I'm using Python 3.7 on Windows 10), and I found a helpful thread here and the BigQuery quickstart guide, BUT when I run

os.environ["GOOGLE_APPLICATION_CREDENTIALS] = "PATH\TO\file_name.json"

I get the error:

  File "<ipython-input-14-ee09f24087ab>", line 1
    os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "C:\Users\Jack\Downloads\StackOverflow-80e374bb80fd.json"
                                                  ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I followed the instructions for getting that file, named myself owner, and did not alter the .json file. Is there a way to change the encoding? I can't find anything about encoding in the docs. Any help would be appreciated, thanks in advance.

Upvotes: 0

Views: 201

Answers (1)

MyNameIsCaleb
MyNameIsCaleb

Reputation: 4489

You need to escape your slashes or it will be read as in invalid unicode character:

"C:\\Users\\Jack\\Downloads\\StackOverflow-80e374bb80fd.json"

Upvotes: 1

Related Questions