質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

YouTube API

YouTube APIはYouTubeのビデオコンテンツと機能性をウェブサイト、アプリケーション、デバイスに統合することを可能にします。

Q&A

解決済

1回答

1562閲覧

youtubeAPIのエラーの原因がわからない。module 'pyparsing' has no attribute 'downcaseTokens'

thaqulla

総合スコア12

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

YouTube API

YouTube APIはYouTubeのビデオコンテンツと機能性をウェブサイト、アプリケーション、デバイスに統合することを可能にします。

0グッド

0クリップ

投稿2022/03/27 14:46

1.youtubeAPI × python で3月中旬からエラーが出てしまう

3月中旬からYouTubeAPIとPythonを組み合わせたプログラムを回すとエラーが出てしまうようになった。
本当はもっと長いプログラムのため、
以下のような簡単なプログラムを書いて実行してもエラーが発生してしまっている。

python

1from apiclient.discovery import build 2 3API_KEY = "自分のAPI_KEY" 4videoId = "WJzSBLCaKc8" #「YouTubeテーマソング/ヒカキン&セイキン」 5 6def YoutubeChannelDetails(videoId,API_KEY): 7 API_SERVICE_NAME = "youtube" 8 API_VERSION = "v3" 9 10 youtube = build(API_SERVICE_NAME, API_VERSION, developerKey=API_KEY) 11 search_response = youtube.videos().list( 12 part="snippet", 13 id = videoId, 14 ).execute() 15 16 return search_response["items"] 17 18test = YoutubeChannelDetails(videoId, API_KEY) 19 20test 21

2.エラーメッセージ

python

1--------------------------------------------------------------------------- 2AttributeError Traceback (most recent call last) 3Input In [4], in <cell line: 1>() 4----> 1 from apiclient.discovery import build 5 3 API_KEY = "自分のAPI_KEY" 6 4 videoId = "WJzSBLCaKc8" 7 8File ~\anaconda3\lib\site-packages\apiclient\__init__.py:6, in <module> 9 3 import googleapiclient 10 5 from googleapiclient import channel 11----> 6 from googleapiclient import discovery 12 7 from googleapiclient import errors 13 8 from googleapiclient import http 14 15File ~\anaconda3\lib\site-packages\googleapiclient\discovery.py:42, in <module> 16 39 import urllib 17 41 # Third-party imports 18---> 42 import httplib2 19 43 import uritemplate 20 44 import google.api_core.client_options 21 22File ~\anaconda3\lib\site-packages\httplib2\__init__.py:52, in <module> 23 48 except ImportError: 24 49 # TODO: remove this fallback and copypasted socksipy module upon py2/3 merge, 25 50 # idea is to have soft-dependency on any compatible module called socks 26 51 from . import socks 27---> 52 from . import auth 28 53 from .error import * 29 54 from .iri2uri import iri2uri 30 31File ~\anaconda3\lib\site-packages\httplib2\auth.py:20, in <module> 32 15 token68 = pp.Combine(pp.Word("-._~+/" + pp.nums + pp.alphas) + pp.Optional(pp.Word("=").leaveWhitespace())).setName( 33 16 "token68" 34 17 ) 35 19 quoted_string = pp.dblQuotedString.copy().setName("quoted-string").setParseAction(unquote) 36---> 20 auth_param_name = token.copy().setName("auth-param-name").addParseAction(pp.downcaseTokens) 37 21 auth_param = auth_param_name + pp.Suppress("=") + (quoted_string | token) 38 22 params = pp.Dict(pp.delimitedList(pp.Group(auth_param))) 39 40AttributeError: module 'pyparsing' has no attribute 'downcaseTokens'

3. やったこと

上記メッセージから

module 'pyparsing' has no attribute 'downcaseTokens'

というエラーが出ているのでpyparsingが悪さをしていると判断。Stackoverflowで調べ、以下のURL先にたどり着いた。
https://stackoverflow.com/questions/69694833/frappe-installation-error-attributeerror-module-pyparsing-has-no-attribute

pyparsingをダウングレードして再度実行したが、同じエラーが出てしまった。

4.今現在の私の環境

Python

1Python 3.8.5 2conda 4.11.0 3 4altair==4.2.0 5altgraph==0.17.2 6apiclient==1.0.4 7argon2-cffi==20.1.0 8asgiref==3.5.0 9astor==0.8.1 10astroid==2.4.2 11async-generator==1.10 12attrs==20.2.0 13backcall==0.2.0 14backports.entry-points-selectable==1.1.0 15backports.zoneinfo==0.2.1 16base58==2.1.1 17bleach==3.2.1 18blinker==1.4 19cachetools==4.2.2 20certifi==2020.6.20 21cffi==1.14.2 22chardet==3.0.4 23charset-normalizer==2.0.4 24click==8.0.3 25colorama==0.4.3 26cycler==0.10.0 27DateTime==4.3 28decorator==4.4.2 29defusedxml==0.6.0 30distlib==0.3.2 31Django==4.0.3 32entrypoints==0.3 33et-xmlfile==1.0.1 34filelock==3.0.12 35future==0.18.2 36gitdb==4.0.9 37GitPython==3.1.26 38google-api-core==2.7.1 39google-api-python-client==2.42.0 40google-auth==2.0.1 41google-auth-httplib2==0.1.0 42google-auth-oauthlib==0.5.1 43googleapis-common-protos==1.53.0 44googletrans==4.0.0rc1 45h11==0.9.0 46h2==3.2.0 47hpack==3.0.0 48hstspreload==2021.12.1 49httpcore==0.9.1 50httplib2==0.20.2 51httpx==0.13.3 52hyperframe==5.2.0 53idna==2.10 54image==1.5.33 55ipykernel==5.3.4 56ipython==7.18.1 57ipython-genutils==0.2.0 58ipywidgets==7.5.1 59isort==5.4.2 60jdcal==1.4.1 61jedi==0.17.2 62Jinja2==2.11.2 63jsonschema==3.2.0 64jupyter==1.0.0 65jupyter-client==6.1.7 66jupyter-console==6.2.0 67jupyter-core==4.6.3 68jupyterlab-pygments==0.1.2 69kiwisolver==1.2.0 70lazy-object-proxy==1.4.3 71lxml==4.7.1 72MarkupSafe==1.1.1 73matplotlib==3.3.2 74mccabe==0.6.1 75mecab==0.996.3 76mecab-python3==1.0.4 77mistune==0.8.4 78multitasking==0.0.10 79mysqlclient==2.0.3 80nbclient==0.5.0 81nbconvert==6.0.7 82nbformat==5.0.7 83nest-asyncio==1.4.0 84notebook==6.1.4 85numpy==1.19.2 86oauth2client==4.1.3 87oauthlib==3.2.0 88openpyxl==3.0.5 89packaging==20.4 90pandas==1.4.0 91pandocfilters==1.4.2 92parso==0.7.1 93pefile==2021.9.3 94pickleshare==0.7.5 95Pillow==7.2.0 96pip-autoremove==0.9.1 97plac==1.3.3 98platformdirs==2.2.0 99prometheus-client==0.8.0 100prompt-toolkit==3.0.7 101protobuf==3.17.3 102pyarrow==6.0.1 103pyasn1==0.4.8 104pyasn1-modules==0.2.8 105pycparser==2.20 106pydeck==0.7.1 107Pygments==2.7.0 108pyinstaller==4.9 109pyinstaller-hooks-contrib==2022.1 110pylint==2.6.0 111Pympler==1.0.1 112pyocr==0.8.1 113pyparsing==2.4.2 114pyrsistent==0.17.3 115python-dateutil==2.8.1 116pytz==2021.3 117pytz-deprecation-shim==0.1.0.post0 118pywin32==228 119pywin32-ctypes==0.2.0 120pywinpty==0.5.7 121pyxel==1.4.3 122pyzmq==19.0.2 123qtconsole==4.7.7 124QtPy==1.9.0 125requests==2.26.0 126requests-oauthlib==1.3.1 127rfc3986==1.5.0 128rsa==4.7.2 129Send2Trash==1.5.0 130six==1.15.0 131smmap==5.0.0 132sniffio==1.2.0 133sqlparse==0.4.2 134streamlit==1.5.0 135terminado==0.8.3 136testpath==0.4.4 137toml==0.10.1 138toolz==0.11.2 139tornado==6.0.4 140tqdm==4.62.3 141traitlets==5.0.4 142tzdata==2021.5 143tzlocal==4.1 144unidic==1.1.0 145uritemplate==3.0.1 146urllib3==1.26.6 147validators==0.18.2 148virtualenv==20.7.2 149wasabi==0.8.2 150watchdog==2.1.6 151wcwidth==0.2.5 152webencodings==0.5.1 153widgetsnbextension==3.5.1 154wrapt==1.12.1 155xlwt==1.3.0 156yfinance==0.1.70 157zope.interface==5.4.0

5.やりたいこと

json形式でitemsのみを以下のように出力したい。

{ "kind": "youtube#video", "etag": etag, "id": string, "snippet": { "publishedAt": datetime, "channelId": string, "title": string, "description": string, "thumbnails": { (key): { "url": string, "width": unsigned integer, "height": unsigned integer } }, "channelTitle": string, "tags": [ string ...

よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

thaqulla

2022/03/27 15:38

httplib2==0.20.2 には既になっていました。
guest

回答1

0

自己解決

1.anaconda3を再インストールで問題解決

VScodeで同様のコードが完走したため、PythonではなくJupyter自体が悪さをしていると判断。Jupyter-notebookを内包するanaconda3を再インストール。

二枚目のように無事完走。

下手に個々のversionを弄るよりもまずは統合開発環境自体を疑うべきでした。猛省。

イメージ説明

イメージ説明

投稿2022/03/29 14:56

thaqulla

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問