首页 > 解决方案 > 在 VM 实例上使用 Jupyter 并访问 BigQuery:“无法访问本地主机”

问题描述

我在 Google Cloud - Compute Engine 上创建了一个 VM 实例。我已经在实例上安装了 Jupyter。我现在想使用笔记本直接在 BigQuery 上查询我的表并使用结果进行分析。

我目前正在执行以下操作:

R = pd.read_gbq(query=Q,project_id = projecti, dialect = 'standard')
R.head()

Q我有一个查询在哪里。

我得到以下输出:

Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbigquery&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=333.apps.googleusercontent.com&access_type=offline

If your browser is on a different machine then exit and re-run this
application with the command-line parameter

  --noauth_local_webserver

我尝试单击链接进行身份验证,但出现“无法访问本地主机”错误。

标签: google-cloud-platformgoogle-bigqueryjupyter-notebookgoogle-compute-engine

解决方案


我有同样的问题,并通过pandas-gbq使用conda包管理器安装解决了它。

conda install pandas-gbq --channel conda-forge

pandas-gbq通过安装时似乎缺少一些链接pip


推荐阅读