Я пытаюсь загрузить видео с Python YouTube
Я не могу решить следующую ошибку?
Я также создал файл JSON
import os
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors
from googleapiclient.http import MediaFileUpload
scopes = ["https://www.googleapis.com/auth/youtube.upload"]
def main():
# Disable OAuthlib's HTTPS verification when running locally.
# *DO NOT* leave this option enabled in production.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
api_service_name = "youtube"
api_version = "v3"
client_secrets_file = "oky.json"
# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes)
credentials = flow.run_console()
youtube = googleapiclient.discovery.build(
api_service_name, api_version, credentials=credentials)
request = youtube.videos().insert(
body={},
# TODO: For this request to work, you must replace "YOUR_FILE"
# with a pointer to the actual file you are uploading.
media_body=MediaFileUpload("video.avi")
)
response = request.execute()
print(response)
if __name__ == "__main__":
main()
Ниже приведен код ошибки
Traceback (most recent call last):
File "/Users/mac/Desktop/xxx/xxx/xxx.py", line 3, in <module>
import google_auth_oauthlib.flow
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google_auth_oauthlib/flow.py", line 65, in <module>
import google_auth_oauthlib.helpers
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google_auth_oauthlib/helpers.py", line 28, in <module>
import requests_oauthlib
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests_oauthlib/__init__.py", line 1, in <module>
from .oauth1_auth import OAuth1
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests_oauthlib/oauth1_auth.py", line 7, in <module>
from oauthlib.oauth1 import Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/oauthlib/oauth1/__init__.py", line 11, in <module>
from .rfc5849 import Client
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 23, in <module>
from . import parameters, signature
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/oauthlib/oauth1/rfc5849/parameters.py", line 14, in <module>
from . import utils
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 14, in <module>
import urllib2
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib2.py", line 220
raise AttributeError, attr
^
SyntaxError: invalid syntax
Я не понял, почему возникла проблема?