Skip to content

ImportError: pandas-gbq requires db-dtypes #873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
khaerulumam42 opened this issue Feb 4, 2025 · 4 comments
Closed

ImportError: pandas-gbq requires db-dtypes #873

khaerulumam42 opened this issue Feb 4, 2025 · 4 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery-pandas API. type: question Request for information or clarification. Not an issue.

Comments

@khaerulumam42
Copy link

Thanks for stopping by to let us know something could be better!

Environment details

  • OS type and version: Debian version 10
  • Python version: 3.8
  • pip version: 24.3.1
  • pandas-gbq version: 0.17.0

Steps to reproduce

  1. pip install pandas-gbq==0.17.0

Code example

import pandas gbq

query = 'some query'

df = pandas_gbq.read_gbq(query, project_id=MY_GOOGLE_PROJECT_ID, credentials=credentials)

Stack trace

File "/opt/venv/lib/python3.8/site-packages/pandas_gbq/gbq.py", line 830, in read_gbq
_test_google_api_imports()
File "/opt/venv/lib/python3.8/site-packages/pandas_gbq/gbq.py", line 46, in _test_google_api_imports
raise ImportError("pandas-gbq requires db-dtypes") from ex
ImportError: pandas-gbq requires db-dtypes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 21, in <module>
service()
File "/app/modules/service.py", line 37, in __exit__
raise exc_type(exc_value)
ImportError: pandas-gbq requires db-dtypes

After I check, this issue because new version of db-dtypes==1.4.0, that just released on 23 January 2025. force use db-dtypes==1.3.1 solve my issue, can you make the dependencies is exactly use db-dtypes==1.3.1?

thank you

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-pandas API. label Feb 4, 2025
@khaerulumam42 khaerulumam42 changed the title update into db-dtypes==1.4.0 create an error ImportError: pandas-gbq requires db-dtypes Feb 5, 2025
@tswast
Copy link
Collaborator

tswast commented Feb 5, 2025

Sorry, I don't understand what action you'd like us to take, could you please clarify?

db-dtypes has been listed as a dependency in setup.py since #423 on Nov 22, 2021

@tswast tswast added the type: question Request for information or clarification. Not an issue. label Feb 5, 2025
@tswast
Copy link
Collaborator

tswast commented Feb 5, 2025

I wonder if this error is related to the unit test failures we're seeing?

__________________ ERROR collecting tests/unit/test_to_gbq.py __________________
ImportError while importing test module '/home/runner/work/python-bigquery-pandas/python-bigquery-pandas/tests/unit/test_to_gbq.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/unit/test_to_gbq.py:11: in <module>
    from pandas_gbq import gbq
pandas_gbq/__init__.py:10: in <module>
    from .gbq import Context, context, read_gbq, to_gbq  # noqa
pandas_gbq/gbq.py:28: in <module>
    import pandas_gbq.schema.pandas_to_bigquery
pandas_gbq/schema/pandas_to_bigquery.py:10: in <module>
    import db_dtypes
.nox/unit-3-9/lib/python3.9/site-packages/db_dtypes/__init__.py:31: in <module>
    from db_dtypes import core
.nox/unit-3-9/lib/python3.9/site-packages/db_dtypes/core.py:22: in <module>
    from db_dtypes import pandas_backports
.nox/unit-3-9/lib/python3.9/site-packages/db_dtypes/pandas_backports.py:75: in <module>
    class OpsMixin:
.nox/unit-3-9/lib/python3.9/site-packages/db_dtypes/pandas_backports.py:59: in <lambda>
    return lambda func_or_class: import_default(module_name, force, func_or_class)
.nox/unit-3-9/lib/python3.9/site-packages/db_dtypes/pandas_backports.py:65: in import_default
    module = __import__(module_name, {}, {}, [name])
E   ModuleNotFoundError: No module named 'pandas.core.arraylike'
=============================== warnings summary ===============================

It seems the latest db-dtypes package is not compatible with pandas==1.1.4.

CC @chelsea-lin

Edit: I see you have a fix in googleapis/python-db-dtypes-pandas#319 I'll cut a db-dtype release so pandas-gbq users can benefit.

@khaerulumam42
Copy link
Author

Sorry not give information clearly, you absolutely right this related to pandas.core.arraylike and should be fix in googleapis/python-db-dtypes-pandas#319.

thanks

@tswast
Copy link
Collaborator

tswast commented Feb 6, 2025

Thanks for confirming. I'm marking this as fixed now that db-dtypes version 1.4.1 has been released.

@tswast tswast closed this as completed Feb 6, 2025
@tswast tswast assigned tswast and unassigned yirutang Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-pandas API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants