python - 为什么我不能用 cmd 运行 python 程序?(但是,使用 Visual Estudio Code 是的)
问题描述
我不能用 cmd 运行 python 程序。
这是我的程序:
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
# 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 ("#---------------------------------------------------------")
store = file.Storage('token.json')
creds = store.get()
drive = build('drive', 'v3', http=creds.authorize(Http()))
file_metadata = {'name': input(str("Introduce como se quiere llamar tu archivo en la nube (intruduce
la extensión) EJEMPLO: photo.jpg o Video.mp4 -----> "))}
media = MediaFileUpload('C:/Users/' + User + '/Desktop/' + input(str("¿Como se llama el archivo q
quieres subir?-----> ")),
mimetype=input(str("Introduce el tipo de archivo que es. EJEMPLO: executable/exe.
Primero de que tipo es, una / y despues la extensión. Y ten en cuenta q el tipo de archivo tiene q
estar en ingles----> ")))
file = drive.files().create(body=file_metadata,
media_body=media,
fields='id').execute()
print ('File ID: %s' % file.get('id'))
这是错误(在 CMD 中):回溯(最近一次调用最后一次):文件“C:\Users\Jose Maria\Desktop\Programación\Python\Subir.py”,第 27 行,在 drive = (build('drive ', 'v3', http=creds.authorize(Http()))) AttributeError: 'NoneType' 对象没有属性 'authorize'
解决方案
推荐阅读
- java - Intellij 无法加载 ModelBuilderService$Ex 类
- c++ - 如何从字符串中删除重复的单词,并且只用它们的字数显示一次
- java - 如何按升序对二维数组进行排序?
- playframework - 为大量并发 SSE 连接扩展 Play 2.7.x(使用 Akka HTTP 服务器)
- java - 如何管理 Dataflow Java 管道中的属性和秘密值?
- python - 是否可以向已编译的封闭源应用程序添加额外的功能,即。微软Word?
- python - Pytorch 点燃 create_supervised_evaluator 不返回自定义指标
- azure - Azure AD B2C 电话因素登录来宾用户
- python - 如何在python中创建循环迭代器?
- mysql - MySQL 同一张表中两个查询的一个结果