Python Google Drive API discovery.build fails with exit code -1073740777 (0xC0000417)
Question: I am building a python application which uploads images to google drive.
However after working for some some time my google drive upload suddenly
stopped working. Whenever I try to initialize the service, the program exits
with code -1073740777 (0xC0000417).

I have already tried to create a new client_secret.json file with the
developer console (also with a completely different Google account) and
deleting the drive-python-quickstart.json credential file.

My friends do not have this problem with the same code and as I said, this has
worked for me for some time, too, but suddenly stopped working.

I am running Windows 10 Pro x64 with Python 3.5 32 Bit.

The problem occurrs when running this example program (taken from [the Google
quickstart guide](https://developers.google.com/drive/web/quickstart/python)):

    
    
    from __future__ import print_function
    import httplib2
    import os
    
    from apiclient import discovery
    import oauth2client
    from oauth2client import client
    from oauth2client import tools
    
    try:
        import argparse
        flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
    except ImportError:
        flags = None
    
    SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
    CLIENT_SECRET_FILE = 'client_secret.json'
    APPLICATION_NAME = 'Drive API Python Quickstart'
    
    
    def get_credentials():
        """Gets valid user credentials from storage.
    
        If nothing has been stored, or if the stored credentials are invalid,
        the OAuth2 flow is completed to obtain the new credentials.
    
        Returns:
            Credentials, the obtained credential.
        """
        home_dir = os.path.expanduser('~')
        credential_dir = os.path.join(home_dir, '.credentials')
        if not os.path.exists(credential_dir):
            os.makedirs(credential_dir)
        credential_path = os.path.join(credential_dir,
                                       'drive-python-quickstart.json')
    
        store = oauth2client.file.Storage(credential_path)
        credentials = store.get()
        if not credentials or credentials.invalid:
            flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
            flow.user_agent = APPLICATION_NAME
            if flags:
                credentials = tools.run_flow(flow, store, flags)
            else: # Needed only for compatibility with Python 2.6
                credentials = tools.run(flow, store)
            print('Storing credentials to ' + credential_path)
        return credentials
    
    def main():
        """Shows basic usage of the Google Drive API.
    
        Creates a Google Drive API service object and outputs the names and IDs
        for up to 10 files.
        """
        credentials = get_credentials()
        http = credentials.authorize(httplib2.Http())
        service = discovery.build('drive', 'v2', http=http)
    
        results = service.files().list(maxResults=10).execute()
        items = results.get('items', [])
        if not items:
            print('No files found.')
        else:
            print('Files:')
            for item in items:
                print('{0} ({1})'.format(item['title'], item['id']))
    
    if __name__ == '__main__':
        main()
    


Answer: Had the same problem while working with Google Youtube API, also had the same
os (Win 10 Pro x64) and used the same version oh python (3.5).

I have no idea how but adding this line in the main function helped

    
    
    sys.modules['win32file'] = None
    

