Getting Youtube data using Python -
i'm trying learn how analyze social media data available on web , i'm starting youtube.
from apiclient.errors import httperror outh2client.tools import argparser apiclient.discovery import build import pandas pd developer_key = "aizasyb_f1mcrdydebguosnzes-nw-mg1caoyji" youtube_api_service_name = "youtube" youtube_api_version = "v3" argparser.add_argument("--q", help="search term", default="apple product") argparser.add_argument("--max-results", help="max results", default=50) args = argparser.parse_args() options = args
and error.
argumenterror traceback (most recent call last) <ipython-input-37-ebbf58549b73> in <module>() ----> 1 argparser.add_argument("--q", help="search term", default="apple product") 2 argparser.add_argument("--max-results", help="max results", default=50) 3 args = argparser.parse_args() 4 options = args /usr/lib/python2.7/argparse.py in add_argument(self, *args, **kwargs) 1306 raise valueerror("length of metavar tuple not match nargs") 1307 -> 1308 return self._add_action(action) 1309 1310 def add_argument_group(self, *args, **kwargs): /usr/lib/python2.7/argparse.py in _add_action(self, action) 1680 def _add_action(self, action): 1681 if action.option_strings: -> 1682 self._optionals._add_action(action) 1683 else: 1684 self._positionals._add_action(action) /usr/lib/python2.7/argparse.py in _add_action(self, action) 1507 1508 def _add_action(self, action): -> 1509 action = super(_argumentgroup, self)._add_action(action) 1510 self._group_actions.append(action) 1511 return action /usr/lib/python2.7/argparse.py in _add_action(self, action) 1320 def _add_action(self, action): 1321 # resolve conflicts -> 1322 self._check_conflict(action) 1323 1324 # add actions list /usr/lib/python2.7/argparse.py in _check_conflict(self, action) 1458 if confl_optionals: 1459 conflict_handler = self._get_handler() -> 1460 conflict_handler(action, confl_optionals) 1461 1462 def _handle_conflict_error(self, action, conflicting_actions): /usr/lib/python2.7/argparse.py in _handle_conflict_error(self, action, conflicting_actions) 1465 option_string, action 1466 in conflicting_actions]) -> 1467 raise argumenterror(action, message % conflict_string) 1468 1469 def _handle_conflict_resolve(self, action, conflicting_actions): argumenterror: argument --q: conflicting option string(s): --q
i'm using tutorial error.
it looks parser import
from outh2client.tools import argparser
already has defined -q
argument. can check looking @ code, or doing argparser.print_help()
(before adding yourself).
so simplest solution choose name argument.
the relevant docs are
https://docs.python.org/3.4/library/argparse.html#conflict-handler
found looking 'conflict' on page.
the parser defined on https://github.com/google/oauth2client/blob/master/oauth2client/tools.py not have -q
argument. source? assume missing a
spelling error.
Comments
Post a Comment