[英]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.