简体   繁体   English

尝试使用来自 google.cloud 的 BigQuery 时出现 ModuleNotFoundError

[英]ModuleNotFoundError when trying to use BigQuery from google.cloud

So when I run my import statement in my python script, I'd get a ModuleNotFoundError.因此,当我在我的 python 脚本中运行我的导入语句时,我会得到一个 ModuleNotFoundError。

    from google.cloud import bigquery
ModuleNotFoundError: No module named 'google'

I've been following https://www.getcensus.com/blog/how-to-hack-it-extracting-data-from-google-bigquery-with-python-2 and I've ran a我一直在关注https://www.getcensus.com/blog/how-to-hack-it-extracting-data-from-google-bigquery-with-python-2并且我运行了一个

pip install --upgrade google-cloud-bigquery

which still hasn't worked这仍然没有奏效

I've tried installing a few other packages from google, but nothing has worked so far.我试过从谷歌安装其他一些软件包,但到目前为止没有任何效果。

You have to create a virtual env in your current project, then install the following package with pip :您必须在当前项目中创建一个虚拟环境,然后安装以下 package 和pip

requirements.txt file requirements.txt文件

google-api-python-client==2.70.0

In your virtual env, run the following command:在您的虚拟环境中,运行以下命令:

pip install -r requirements.txt

Then you will be able to import the expected elements from the library:然后您将能够从库中导入预期的元素:

from google.cloud import bigquery

Check your Python version and use Python 3 .检查您的 Python 版本并使用Python 3

暂无
暂无

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

相关问题 无法在 python 脚本中使用 google.cloud(存储) - Unable to use google.cloud (storage) from within a python script ImportError:无法从“google.cloud”(未知位置)导入名称“aiplatform” - ImportError: cannot import name 'aiplatform' from 'google.cloud' (unknown location) 从 Google Cloud Storage 加载 csv 文件时出现 BigQuery 错误 - BigQuery error when loading csv file from Google Cloud Storage 无法在 Airflow 2.0 中使用“from airflow.providers.google.cloud.operators.bigquery import BigQueryOperator” - Not being able to use 'from airflow.providers.google.cloud.operators.bigquery import BigQueryOperator' in Airflow 2.0 将表从 Google BigQuery 导出到 Google Cloud Storage 时出现权限错误 - Permissions Error Exporting a table from Google BigQuery to Google Cloud Storage Pycharm 在 google.cloud 的“__init__.pyi”中找不到引用“cloud”,但代码确实执行 - Pycharm cannot find reference `cloud` in "__init__.pyi" for google.cloud, but code does execute ModuleNotFoundError:没有名为“google.cloud.location”的模块 - ModuleNotFoundError: No module named 'google.cloud.location' BigQuery 中的循环 (SQL - GOOGLE CLOUD) - Loop in BigQuery (SQL - GOOGLE CLOUD) Google Cloud Dataflow:ModuleNotFoundError:运行集成测试时没有名为“main”的模块 - Google Cloud Dataflow: ModuleNotFoundError: No module named 'main' when running integration test 为什么我在尝试从本地谷歌云 function 连接到谷歌云 MySQL db 时收到 sqlalchemy.exc.OperationalError? - Why am I getting sqlalchemy.exc.OperationalError when trying to connect to Google Cloud MySQL db from a local google cloud function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM