导入 pyarrow 不起作用 <- 错误是“ValueError:未安装 pyarrow 库,请安装 pyarrow 以使用 to_arrow() 函数。”

Sar*_*ead 9 google-bigquery jupyter pyarrow

我尝试在终端和 juypter 实验室中安装它,它说它已成功安装,但是当我运行 df = query_job.to_dataframe() 时,我不断收到错误“ ValueError: The pyarrow library is not installed, please install pyarrow使用 to_arrow() 函数。”。我不知道如何解决这个问题。有什么建议吗?我试图最终使用代码从谷歌数据工作室访问数据,

from google.cloud import bigquery
import pandas
import numpy
import pyarrow
bigquery_client = bigquery.Client()
import os 
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] ='full file path here.json'
QUERY = """
SELECT * 
FROM `warehouse`
LIMIT 100
"""
query_job = bigquery_client.query(QUERY)
df = query_job.to_dataframe()
Run Code Online (Sandbox Code Playgroud)

小智 7

我遇到过同样的问题。修复后如下:

pip install --upgrade 'google-cloud-bigquery[bqstorage,pandas]'
Run Code Online (Sandbox Code Playgroud)

来源:https ://cloud.google.com/bigquery/docs/bigquery-storage-python-pandas


juf*_*afo 6

ModuleNotFoundError: No module named 'pyarrow'在测试您的 Python 代码时,我收到了相同的错误消息。安装后,这种现象消失pyarrow与依赖pip install pyarrow