python - NameError: name 'argv' is not defined -
i trying make google api call , getting error beginning of code found here:
import os import argparse import sys apiclient import sample_tools oauth2client import client # declare command-line flags. argparser = argparse.argumentparser(add_help=false) argparser.add_argument( 'profile_id', type=int, help='the id of profile campaigns for') # authenticate , construct service. service, flags = sample_tools.init( argv[1:], 'dfareporting', 'v2.1', __doc__, os.path.abspath(os.path.dirname("__file__")), parents=[argparser], scope=['https://www.googleapis.com/auth/dfareporting', 'https://www.googleapis.com/auth/dfatrafficking']) if __name__ == '__main__': main(sys.argv) however, sample_tools.init function not returning service , flags object. think have isolated argv argument a
nameerror: name 'argv' not defined any appreciated!!!
you missing sys:
sys.argv[1:] you either need from sys import argv , use argv everywhere or import sys have , use sys.argv. don't see main function anywhere main(sys.argv) going cause nameerror
Comments
Post a Comment