我已在Google Developers Console上注册,但我的项目不是结算项目。我做了“初始化环境”和“构建并运行”的步骤 “正如网页https://github.com/GoogleCloudPlatform/datalab/wiki/Development-Environment和https://github.com/GoogleCloudPlatform/datalab/wiki/Build-and-Run所描述的那样。 但是当我在本地linux服务器上部署的Notebook中运行代码时,我遇到了以下错误:
异常回溯(最近一次调用最后一次) in() 1#创建并运行SQL查询 ----> 2 bq.Query('SELECT * FROM [cloud-datalab-samples:httplogs.logs_20140615] LIMIT 3')。results()
/usr/local/lib/python2.7/dist-packages/gcp/bigquery/_query.pyc in results(self,use_cache) 130“”“ 131如果不是use_cache或(self._results为None): - > 132 self.execute(use_cache = use_cache) 133返回self._results.results 134
执行中的 /usr/local/lib/python2.7/dist-packages/gcp/bigquery/_query.pyc(self,table_name,table_mode,use_cache,priority,allow_large_results) 343“”“ 344 job = self.execute_async(table_name = table_name,table_mode = table_mode,use_cache = use_cache, - > 345 priority = priority,allow_large_results = allow_large_results) 346 self._results = job.wait() 347返回self._results execute_async中的例外:无法发送HTTP请求。 一步一步,我发现抛出异常的地方: 如果标题为无: headers = {}
headers['user-agent'] = 'GoogleCloudDataLab/1.0'
# Add querystring to the URL if there are any arguments.
if args is not None:
qs = urllib.urlencode(args)
url = url + '?' + qs
# Setup method to POST if unspecified, and appropriate request headers
# if there is data to be sent within the request.
if data is not None:
if method is None:
method = 'POST'
if data != '':
# If there is a content type specified, use it (and the data) as-is.
# Otherwise, assume JSON, and serialize the data object.
if 'Content-Type' not in headers:
data = json.dumps(data)
headers['Content-Type'] = 'application/json'
headers['Content-Length'] = str(len(data))
else:
if method == 'POST':
headers['Content-Length'] = '0'
# If the method is still unset, i.e. it was unspecified, and there
# was no data to be POSTed, then default to GET request.
if method is None:
method = 'GET'
# Create an Http object to issue requests. Associate the credentials
# with it if specified to perform authorization.
#
# TODO(nikhilko):
# SSL cert validation seemingly fails, and workarounds are not amenable
# to implementing in library code. So configure the Http object to skip
# doing so, in the interim.
http = httplib2.Http()
http.disable_ssl_certificate_validation = True
if credentials is not None:
http = credentials.authorize(http)
try:
response, content = http.request(url,method=method,body=data,headers=headers)
if 200 <= response.status < 300:
if raw_response:
return content
return json.loads(content)
else:
raise RequestException(response.status, content)
except ValueError:
raise Exception('Failed to process HTTP response.')
except httplib2.HttpLib2Error:
raise Exception('Failed to send HTTP request.')
我想知道这是我的配置错误还是cloud datalab不支持本地部署和运行。也就是说,我们无法在本地datalab服务器上的笔记本中运行代码。 请给我一些想法。问题困扰了我一周!谢谢!
答案 0 :(得分:1)
如果您希望在本地运行Datalab容器而不是在Google Cloud中运行它,那么也可以如下所述: https://github.com/GoogleCloudPlatform/datalab/wiki/Build-and-Run
然而,这是用于构建/更改Datalab代码的开发人员设置,目前还没有面向希望使用Datalab作为工具的数据科学家/开发人员。即与仅将Datalab部署到启用计费的云项目相比,设置起来更复杂。即使使用本地运行容器,您也可能希望使用Google Cloud项目来运行BigQuery查询等
答案 1 :(得分:0)
如果你的项目没有启用计费,你就无法对BigQuery运行查询,这就是你想要做的事情。
答案 2 :(得分:0)
按照标题为Run Cloud Datalab locally的快速入门指南中的步骤在本地运行datalab,而无需设置datalab开发环境。