首页 文章

如何在我的本地Linux服务器上运行google-cloud-datalab?

提问于
浏览
1

我已在Google Developers Console上注册,但我的项目不是结算项目 . 我做了网页https://github.com/GoogleCloudPlatform/datalab/wiki/Development-Environmenthttps://github.com/GoogleCloudPlatform/datalab/wiki/Build-and-Run描述的“初始化环境”和“构建并运行”的步骤 . 但是当我在本地Linux服务器上部署的Notebook中运行代码时,我遇到以下错误:

创建并运行SQL查询

bq.Query('SELECT * FROM [cloud-datalab-samples:httplogs.logs_20140615] LIMIT 3') . results()

()中的异常回溯(最近一次调用)1#创建并运行SQL查询----> 2 bq.Query('SELECT * FROM [cloud-datalab-samples:httplogs.logs_20140615] LIMIT 3') . 结果()

结果中的/usr/local/lib/python2.7/dist-packages/gcp/bigquery/_query.pyc(self,use_cache)130“”“131 if if use_cache或(self._results is 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 return self._results

execute_async中的/usr/local/lib/python2.7/dist-packages/gcp/bigquery/_query.pyc(self,table_name,table_mode,use_cache,priority,allow_large_results)307 allow_large_results = allow_large_results)308除了异常为e: - > 309如果'jobReference'不在query_result中,则提高e 310:311引发异常('意外的查询响应' . )

Exception: Failed to send HTTP request. 一步一步,我找到抛出异常的地方:如果 Headers 是None: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服务器上的笔记本中运行代码 . 请给我一些想法 . 这个问题扰乱了我一周!谢谢!

3 回答

  • 1

    如果您希望在本地运行Datalab容器而不是在Google Cloud中运行它,那么也可以如下所述:https://github.com/GoogleCloudPlatform/datalab/wiki/Build-and-Run

    然而,这是用于构建/更改Datalab代码的开发人员设置,目前还没有面向希望使用Datalab作为工具的数据科学家/开发人员 . 即与仅将Datalab部署到启用计费的 Cloud 项目相比,设置起来更复杂 . 即使使用本地运行容器,您也可能希望使用Google Cloud项目来运行BigQuery查询等

  • 0

    如果您的项目没有启用计费,则无法对BigQuery运行查询,这就是您尝试执行的操作 .

  • 0

    按照 Headers 为Run Cloud Datalab locally的快速入门指南中的步骤在本地运行datalab,而无需设置datalab开发环境 .

相关问题