Python 3.x 未解析引用';MediaFileUpload';

Python 3.x 未解析引用';MediaFileUpload';,python-3.x,google-api-python-client,Python 3.x,Google Api Python Client,我试图在python中使用Google driveApi,但我遇到了这个错误,我安装了所有必要的依赖项,但我仍然遇到了这个问题,无法解决: Traceback (most recent call last): File "C:/Users/User/PycharmProjects/dandalo/GoogleDriveAPI.py", line 2, in <module> class UploadToGoogleDrive: File "C:/Users/User/

我试图在python中使用Google driveApi,但我遇到了这个错误,我安装了所有必要的依赖项,但我仍然遇到了这个问题,无法解决:

Traceback (most recent call last):
File "C:/Users/User/PycharmProjects/dandalo/GoogleDriveAPI.py", line 2, in 
   <module>
    class UploadToGoogleDrive:
File "C:/Users/User/PycharmProjects/dandalo/GoogleDriveAPI.py", line 20, in 
UploadToGoogleDrive
    media = googleapiclient.MediaFileUpload('files/photo.jpg',
AttributeError: module 'googleapiclient' has no attribute 'MediaFileUpload'

只需将其添加到代码中

from apiclient.http import MediaFileUpload

您正在尝试从
GoogleAppClient
导入MediaFileUpload

来自
GoogleAppClient中的http模块

试试这个
media=googleapiclient.http.MediaFileUpload('files/photo.jpg')

可能重复的
from apiclient.http import MediaFileUpload