You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将BigQuery查询结果转换为DataFrame时出现PyArrow导入错误

Solutions for PyArrow Import Error When Using BigQuery to_dataframe()

Here are actionable fixes to resolve the PyArrow import error you're encountering:

  • Verify PyArrow version compatibility
    The google-cloud-bigquery library has strict version requirements for PyArrow. Run pip show google-cloud-bigquery and check the Requires-Dist field to see the supported PyArrow version range. Install the correct version with:

    pip install pyarrow==<compatible_version>
    

    Alternatively, install the google-cloud-bigquery package with its pyarrow extra to automatically get a compatible version:

    pip install google-cloud-bigquery[pyarrow]
    
  • Confirm your Python environment
    Ensure you're working in the correct virtual environment where PyArrow is installed. Run pip list to check if PyArrow appears in the package list. If not, activate the right environment and reinstall the packages there.

  • Reinstall corrupted packages
    Corrupted installations can cause import issues. Uninstall and reinstall the relevant packages:

    pip uninstall -y google-cloud-bigquery pyarrow
    pip install google-cloud-bigquery pyarrow
    
  • Check for conflicting local files
    Make sure there are no files named pyarrow.py or directories named pyarrow in your project root. These will shadow the official PyArrow library and prevent proper imports.

  • Alternative: Use pandas-gbq directly
    If the above fixes don't work, bypass the to_dataframe() method by using pandas-gbq to fetch the query results directly into a DataFrame:

    import pandas as pd
    from google.oauth2 import service_account
    
    credentials_path = "credential path"
    credentials = service_account.Credentials.from_service_account_file(credentials_path)
    project_id = "project id"
    
    df = pd.read_gbq(
        "SELECT * FROM table",
        project_id=project_id,
        credentials=credentials
    )
    

内容的提问来源于stack exchange,提问作者Chris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 12:20:27