Oauth 初始化.bigqueryrc配置文件时出现错误

Oauth 初始化.bigqueryrc配置文件时出现错误,oauth,google-bigquery,Oauth,Google Bigquery,我开始通过命令行使用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. *

我开始通过命令行使用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 API的web url,这是它第一次给我错误:无效的\u请求。第二次,我能够链接我的一个谷歌帐户,并给予它许可。它给了我一个密码。当我编写代码时,它给了我以下输出:

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命令,它将再次为我提供相同的web url,但它会一次又一次地提供无效的_请求错误

我能做什么?我要链接并授予权限的帐户已链接到已启用Bigquery的项目


谢谢。

看起来您在Windows配置和Python实现的“查找主目录”(更具体地说,是os.path.expanduser(“~”)之间遇到了问题

谢谢你让我们注意到这一点。我在上为这个问题提交了一个跟踪bug

以下是一些您可以采用的解决方案:

首先,您可以指定bq需要使用的文件的确切路径:

bq --bigqueryrc=<path to your settings file> --credential_file=<path to your credentials file>
bq--bigqueryrc=--credential\u文件=
创建bigqueryrc文件后,可以向其中添加此行:

credential_file=<path to your credentials file>
credential\u文件=
然后,每当bq开始使用bigqueryrc文件时,它总是应用rc文件中指定的命令行标志,并选择正确的凭证文件。好处:从长远来看,打字的次数较少

其次,您可以尝试纠正Python和Windows之间的问题


看起来Python的实现优先考虑了环境变量HOME,然后是环境变量USERPROFILE。如果由于某种原因没有配置这些文件,您可以将它们设置为指向您的用户目录。

谢谢您的报告Mauricio。您能否提供有关Windows 7安装的一些详细信息,以帮助我们重现并解决此问题?您的HOME和USERPROFILE环境设置为什么?Windows应该自动设置USERPROFILE,但由于某些原因,情况似乎并非如此。(我还看到一些Python错误,这些错误是关于如何正确处理用户配置文件目录名中包含Unicode字符的Windows的,这可能也会影响您。如果是这样,我在下面的文章中的第一个解决方法应该对您有效。)HOME变量设置为%USERPROFILE%,但没有USERPROFILE环境变量。