[英]ValueError: install DBtypes to use this function
I'm using BigQuery for the first time.我是第一次使用 BigQuery。
client.list_rows(table, max_results = 5).to_dataframe();
Whenever I use to_dataframe() it raises this error:每当我使用 to_dataframe() 时,它都会引发此错误:
ValueError: Please install the 'db-dtypes' package to use this function.
ValueError:请安装“db-dtypes”package 以使用此 function。
I found this similar problem (almost exactly the same), but I can't understand how to implement their proposed solution.我发现了这个类似的问题(几乎完全一样),但我不明白如何实施他们提出的解决方案。
The most robust way to resolve this is to specify that you also want to install the pandas
extra dependencies when installing the google-cloud-bigquery
package.解决此问题的最可靠方法是指定在安装
google-cloud-bigquery
package 时还需要安装pandas
额外依赖项。 You'd do this by你会这样做
pip install 'google-cloud-bigquery[pandas]'
, orpip install 'google-cloud-bigquery[pandas]'
,或google-cloud-bigquery[pandas]==2.34.3
in your requirements.txt
.google-cloud-bigquery[pandas]==2.34.3
放入您的requirements.txt
。I was able to replicate your use case as shown below.我能够复制您的用例,如下所示。
Easiest solution is to pip install db-dtypes
as mentioned by @MattDMo.最简单的解决方案是
pip install db-dtypes
如@MattDMo 所述。
Or you can specify previous version of google-cloud-bigquery
by creating a requirements.txt
with below contents:或者,您可以通过创建包含以下内容的
requirements.txt
来指定以前版本的google-cloud-bigquery
:
google-cloud-bigquery==2.34.3
And then pip install by using command as shown below:然后使用命令进行 pip install ,如下所示:
pip install -r /path/to/requirements.txt
Make sure pandas
is installed.确保已安装
pandas
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.