首页 > 解决方案 > import pyarrow not working <- error is "ValueError: The pyarrow library is not installed, please install pyarrow to use the to_arrow() function."

问题描述

我尝试在终端和 juypter lab 中安装它,它说它已成功安装,但是当我运行 df = query_job.to_dataframe() 时,我不断收到错误“ValueError:未安装 pyarrow 库,请安装 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()

标签: google-bigqueryjupyterpyarrow

解决方案


ModuleNotFoundError: No module named 'pyarrow'在测试您的 Python 代码时,我收到了相同的错误消息。pyarrow使用 . 安装依赖项后,此行为消失了pip install pyarrow

编辑:一旦我在运行后重新启动内核,它就对我有用pip install pyarrow


推荐阅读