0

I can't execute the code, because I get the following error error:ModuleNotFoundError: No module named 'apiclient.http'.

Module apiclient, is installed and this is my code:

from __future__ import print_function
import getpass
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
from apiclient.http import MediaFileUpload
import time
import os.path

archivos = input(str("Introduce como quieres que se llame ese archivo en la nube. INCLUYENDO LA 
EXTENSIÓN DEL ARCHIVO---->  "))

extension = os.path.splitext(archivos)

Extension = extension[1] 
print (Extension[1])
if Extension == ".jpg":
    Extension = 'image/jpg'
   # If modifying these scopes, delete the file token.json.
    SCOPES = 'https://www.googleapis.com/auth/drive'
    User = getpass.getuser()
    print ("---------------------------------------------------------")
    print ("                   PROGRAMA PARA SUBIR                   ")
    print ("---------------------------------------------------------")
    time.sleep(1)
    store = file.Storage('token.json')
    creds = store.get()
    drive = (build('drive', 'v3', http=creds.authorize(Http())))
    file_metadata = {'name': extension }
    media = MediaFileUpload('C:/Users/' + User + '/Desktop/' + input(str("¿Como se llama el archivo q 
 quieres subir? (Carpeta donde tiene que estar el archivo es el escritorio)----->   ")),
                            mimetype= Extension)
    time.sleep(0.5)
    file = drive.files().create(body=file_metadata,
                                          media_body=media,
                                         fields='id').execute()
Elidor00
  • 1,271
  • 13
  • 27
  • Try to check this post https://stackoverflow.com/questions/35982655/python-install-module-apiclient – Elidor00 Oct 08 '20 at 14:53
  • As per the [Drive API Documentation > Python Quickstart](https://developers.google.com/drive/api/v3/quickstart/python#step_2_install_the_google_client_library) says. You should install `pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib`. If you've already done that, then can you please list the modules installed locally in your environment? Use `sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()])` . – Jose Vasquez Oct 09 '20 at 08:01
  • I've solved it, thank you so much for your help – Josema3579 Oct 10 '20 at 10:33

0 Answers0