我开始通过命令行使用Google的大查询工具,我尝试运行命令
>bq init
它提供此输出
Welcome to BigQuery! This script will walk you through the
process of initializing your .bigqueryrc configuration file.
First, we need to set up your credentials if they do not
already exist.
******************************************************************
** No OAuth2 credentials found, beginning authorization process **
******************************************************************
Go to the following link in your browser:
这里出现了google apis的网址,这是它第一次给我错误:invalid_request。我第二次能够链接我的一个谷歌帐户并给予许可。它给了我一个代码。当我编写该代码时,它给了我这个输出:
You have encountered a bug in the BigQuery CLI. Google engineers monitor and
answer questions on Stack Overflow, with the tag google-bigquery:
http://stackoverflow.com/questions/ask?tags=google-bigquery
Please include a brief description of the steps that led to this issue, as well
as the following information:
========================================
== Platform ==
CPython:2.7.6:Windows-7-6.1.7601-SP1
== bq version ==
v2.0.17
== Command line ==
['D:\\Python27\\scripts\\bq-script.py', 'init']
== UTC timestamp ==
2013-11-26 14:09:11
== Error trace ==
File "build\bdist.win-amd64\egg\bq.py", line 783, in RunSafely
return_value = self.RunWithArgs(*args, **kwds)
File "build\bdist.win-amd64\egg\bq.py", line 2082, in RunWithArgs
client = Client.Get()
File "build\bdist.win-amd64\egg\bq.py", line 604, in Get
cls.client = Client.Create()
File "build\bdist.win-amd64\egg\bq.py", line 584, in Create
credentials = _GetCredentialsFromFlags()
File "build\bdist.win-amd64\egg\bq.py", line 390, in _GetCredentialsFromFlags
credentials = credentials_getter(storage)
File "build\bdist.win-amd64\egg\bq.py", line 330, in _GetCredentialsFromOAuthF
low
credentials = oauth2client.tools.run(flow, storage)
File "build\bdist.win-amd64\egg\oauth2client\util.py", line 132, in positional
_wrapper
return wrapped(*args, **kwargs)
File "build\bdist.win-amd64\egg\oauth2client\old_run.py", line 156, in run
storage.put(credential)
File "build\bdist.win-amd64\egg\oauth2client\client.py", line 325, in put
self.locked_put(credentials)
File "build\bdist.win-amd64\egg\oauth2client\file.py", line 111, in locked_put
self._create_file_if_needed()
File "build\bdist.win-amd64\egg\oauth2client\file.py", line 97, in _create_fil
e_if_needed
open(self._filename, 'a+b').close()
========================================
Unexpected exception in init operation: [Errno 2] No such file or directory:
'%USERPROFILE%\\.bigquery.v2.token'
不知道它是什么。现在,如果我再次尝试运行init命令,它将再次给我相同的网址,但它一遍又一遍地给我Invalid_request错误。
我该怎么办?我想要链接并授予权限的帐户已链接到已启用Bigquery的项目。
感谢。
答案 0 :(得分:2)
看起来你在Windows配置和Python的“查找主目录”(更具体地说,os.path.expanduser('〜'))的实现之间遇到了问题。
感谢您提请我们注意。我在https://code.google.com/p/google-bigquery/issues/detail?id=55&thanks=55&ts=1385494081处针对此问题提交了跟踪错误。
以下是一些有关您可以追求的想法的工作:
首先,您可以指定bq需要使用的文件的确切路径:
bq --bigqueryrc=<path to your settings file> --credential_file=<path to your credentials file>
创建bigqueryrc文件后,您可以将此行添加到其中:
credential_file=<path to your credentials file>
然后每当bq开始使用你的bigqueryrc文件时,它将始终应用你的rc文件中指定的命令行标志并获取正确的凭证文件。好处:从长远来看,减少打字。
其次,您可以尝试纠正Python和Windows之间的问题。
看起来Python的expanduser实现优先考虑环境变量HOME,然后是环境变量USERPROFILE。如果由于某种原因未配置它们,您可以将它们设置为指向您的用户目录。