简体   繁体   English

ValueError:安装 DBtypes 以使用此 function

[英]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你会这样做

  • running pip install 'google-cloud-bigquery[pandas]' , or运行pip install 'google-cloud-bigquery[pandas]' ,或
  • putting eg 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

Output of my sample replication:我的样本复制的输出: 在此处输入图像描述

Make sure pandas is installed.确保已安装pandas

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

相关问题 数据管道运行时出现ValueError Python function - ValueError when running Python function in data pipeline 无法卸载/安装/使用 gcloud cli - Unable to uninstall / install / use the gcloud cli 无法在 lambda 层中安装库并在 lambda 层自定义脚本中使用它 - Cannot install a library in lambda layer and use it in lambda layer custom script 如何在 Python Azure Function Docker 容器中安装 pdfkit/wkhtmltopdf? - How to install pdfkit/wkhtmltopdf in Python Azure Function Docker Container? 如何在Redshift中使用window function? - How to use window function in Redshift? 如何在lambda function中使用pyhive? - how to use pyhive in lambda function? 如何在 Azure function 应用程序中安装 python 模块 - How to install python modules in a Azure function app 如何使用 navigator.sendBeacon() 执行 function? - How to use navigator.sendBeacon() to execute a function? PIL ValueError:图像数据不足? - PIL ValueError: not enough image data? 如何在 Amazon EC2 Linux 实例上安装和使用 Python 3.8? - How do I install and use Python 3.8 on an Amazon EC2 Linux Instance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM