1

I installed the google API, pyDrive, and httplib2. I also got a token for my app in google and saved the client_secret.json file in my project's folder. I'm trying to simply run the following

print(sys.path)

from pydrive.auth import GoogleAuth

gauth = GoogleAuth()

gauth.LocalWebserverAuth() # Creates local webserver and auto handles     authentication

but it throws a syntax error invalid syntax (auth.py, line 160) in the line

from pydrive.auth import GoogleAuth

I can authenticate the app using the google drive API (without pydrive) but I'm unable to use pyDrive because of the described error, I've tried to append the following lines at the beginning of the script:

import sys
if "C:\\Users\\giovanni.sumano\\AppData\\Local\\Continuum\\Anaconda3\\Lib\\site-packages\\pydrive" not in sys.path:
sys.path.append("C:\\Users\\giovanni.sumano\\AppData\\Local\\Continuum\\Anaconda3\\Lib\\site-packages\\pydrive")

because C:\\Users\\giovanni.sumano\\AppData\\Local\\Continuum\\Anaconda3\\Lib\\site-packages\\pydrive is the only path where I've found pydrive libraries, additionally I've tried to add the path to the PYTHONPATH environment variable via cmd, neither has worked for me so far. Does anybody know how can I make pyDrive work for me?

I'm running python on windows 8.1 and visual studio and python tools for visual studio.

dirn
  • 19,454
  • 5
  • 69
  • 74
  • 1
    If `from pydrive.auth import GoogleAuth` is line 160 of `auth.py`, the `invalid syntax` error occurs somewhere **before** this line. I suggest commenting out the preceding lines of code one at a time to determine which line actually contains the syntax error. – Code-Apprentice Feb 02 '16 at 23:27
  • Are you running this in 2.x? If so, the error is with that print call. – mechanical_meat Feb 02 '16 at 23:29
  • Hi, thanks for your response @dim. Even If I delete everything before `from pyDrive.auth import GoogleAuth` I still get the error, I haven't been able to use dyDrive. – Giovanni Francis Sumano Arias Feb 03 '16 at 17:20
  • Just in case, do you have any package named **pydrive** or **auth.py** on your project? Sometimes I create .py files with the same name of the package and I have problems – Filipe Spindola Jun 20 '16 at 00:54
  • @GiovanniFrancisSumanoArias the secrets file should be named `client_secrets.json` (note the 's'). If you are still experiencing this bug you can open an issue on [GitHub](https://github.com/googledrive/PyDrive). – Robin Nabel Jun 20 '16 at 14:52

0 Answers0