Python Youtube api::通过命令行设置元数据字段

Python Youtube api::通过命令行设置元数据字段,python,youtube-api,argparse,Python,Youtube Api,Argparse,对于这个基本问题,我很抱歉,但我一直在到处寻找通过命令行调用youtube api的示例,以及如何设置其正确的元数据字段 以下代码由谷歌提供: 我遵循了这里给出的示例: 例如,在搜索Karma警察视频时,我尝试了相应的方法: $python script.py--q=“karma police”,没有用。它什么也不印 我错过了什么 ps.在同一目录下的环境.json文件中设置更多凭据 编辑:回溯: Traceback (most recent call last): File "audio.

对于这个基本问题,我很抱歉,但我一直在到处寻找通过
命令行
调用
youtube api
的示例,以及如何设置其正确的元数据字段

以下代码由谷歌提供:

我遵循了这里给出的示例:

例如,在搜索Karma警察视频时,我尝试了相应的方法:

$python script.py--q=“karma police”
,没有用。它什么也不印

我错过了什么

ps.在同一目录下的环境
.json文件中设置更多凭据

编辑:回溯:

Traceback (most recent call last):
  File "audio.py", line 64, in <module>
    youtube_search(args)
  File "audio.py", line 24, in youtube_search
    developerKey=DEVELOPER_KEY)
  File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/googleapiclient/discovery.py", line 226, in build
    credentials=credentials)
  File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/googleapiclient/discovery.py", line 358, in build_from_document
    credentials = _auth.default_credentials()
  File "/Library/Python/2.7/site-packages/googleapiclient/_auth.py", line 41, in default_credentials
    return oauth2client.client.GoogleCredentials.get_application_default()
  File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 1264, in get_application_default
    return GoogleCredentials._get_implicit_credentials()
  File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 1249, in _get_implicit_credentials
    credentials = checker()
  File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 1200, in _implicit_credentials_from_files
    credentials_filename = _get_environment_variable_file()
  File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 1348, in _get_environment_variable_file
    ' environment variable) does not exist!')
oauth2client.client.ApplicationDefaultCredentialsError: File “/Users//api/youtube/urlaudio/myproject.json” (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
回溯(最近一次呼叫最后一次):
文件“audio.py”,第64行,在
youtube_搜索(args)
文件“audio.py”,第24行,在youtube_搜索中
developerKey=DEVELOPER\u键)
文件“/Library/Python/2.7/site packages/oauth2client/_helpers.py”,第133行,在位置包装中
已包装退货(*args,**kwargs)
文件“/Library/Python/2.7/site packages/googleapiclient/discovery.py”,第226行,内部版本
凭证=凭证)
文件“/Library/Python/2.7/site packages/oauth2client/_helpers.py”,第133行,在位置包装中
已包装退货(*args,**kwargs)
文件“/Library/Python/2.7/site packages/googleapiclient/discovery.py”,第358行,来自文档的内部版本
凭据=\u auth.default\u凭据()
默认凭据中的文件“/Library/Python/2.7/site packages/googleapiclient/_auth.py”,第41行
返回oauth2client.client.GoogleCredentials.get_应用程序_默认值()
文件“/Library/Python/2.7/site packages/oauth2client/client.py”,第1264行,默认为get\u应用程序
返回Google凭据。\u获取\u隐式\u凭据()
文件“/Library/Python/2.7/site packages/oauth2client/client.py”,第1249行,在“获取”和“隐式”凭证中
凭据=检查程序()
文件“/Library/Python/2.7/site packages/oauth2client/client.py”,第1200行,在\u文件的\u隐式\u凭证\u中
凭据\u文件名=\u获取\u环境\u变量\u文件()
文件“/Library/Python/2.7/site packages/oauth2client/client.py”,第1348行,在get_环境_变量_文件中
“环境变量”不存在!')
oauth2client.client.ApplicationDefaultCredentialsError:File“/Users//api/youtube/urlaudio/myproject.json”(由GOOGLE\u APPLICATION\u CREDENTIALS环境变量指向)不存在!
按照以下步骤操作。最后,您需要指向您下载的json文件,例如:

export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/youtube-search-b0e0b347241c.json

当然,您最好将该文件移到安全的地方,例如,将其放入
~/.credentials/
chmod 700
目录中。

它不会打印任何内容吗?所以它没有到达这一行:
打印“Videos:\n”,“\n”.join(Videos),“\n”
是否检查了执行到达的距离?e、 g.我通常只是在行之间添加一些
print('1')
code,以检查执行停止点在我的机器上的工作位置:-)请参见
python--version
?怎么说?不,它现在打印出那个错误。我将使用回溯编辑问题。
export GOOGLE_APPLICATION_CREDENTIALS=~/Downloads/youtube-search-b0e0b347241c.json