简体   繁体   English

google.cloud在哪个python库中?

[英]In what python library is google.cloud?

I've used pip (and pip3) to install google-api-python-client, all over the place, but whenever I try to issue 我已经使用pip(和pip3)在各处安装了google-api-python-client,但是无论何时尝试发布

from google.cloud import bigquery

I get an 我得到一个

ImportError: No module named google.cloud" error. ImportError:没有名为google.cloud的模块”错误。

sys.path contains the directory that pip reports google-api-python-client is installed in, although it's near the end of a long(ish) list of directories. sys.path包含pip报告安装了google-api-python-client的目录,尽管它位于一长串目录的末尾。

Edit: 编辑:

I've also installed google-cloud. 我还安装了google-cloud。 The error occurs with both libraries installed. 安装两个库都发生错误。

Edit2: the Location for both are: "/home/swood/.local/lib/python3.5/site-packages" Edit2:两者的位置是:“ /home/swood/.local/lib/python3.5/site-packages”

print(sys.path) returns: ['/mnt/pasnas00/dbdata/snowflakedata/lib', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/home/swood/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages'] print(sys.path)返回:['/ mnt / pasnas00 / dbdata / snowflakedata / lib','/usr/lib/python35.zip','/usr/lib/python3.5','/ usr / lib / python3.5 / plat-x86_64-linux-gnu','/ usr / lib / python3.5 / lib-dynload','/ home / swood / .local / lib / python3.5 / site-packages','/ usr / local / lib / python3.5 / dist-packages”,“ / usr / lib / python3 / dist-packages”]

That's because those are different libraries. 那是因为那些是不同的库。 You have installed the Google API Client and trying to import the Google Cloud one. 您已经安装了Google API客户端,并尝试导入Google Cloud 客户端 For an overview of the differences you can refer to this documentation . 有关差异的概述,请参考此文档

Install it with this instead: 与此相反安装它:

pip install google-cloud

or with pip3 for Python3. 或使用pip3适用于Python3)。 If you still want to use the other Client you'll need to import it and build the BigQuery service with something like this: 如果您仍想使用其他客户端,则需要将其导入并使用以下内容构建BigQuery服务:

from googleapiclient.discovery import build
...
service = build('bigquery', 'v2', credentials=credentials)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM