Skip to content
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

Image reports error ModuleNotFoundError: No module named '_bz2' when importing pandas #549

Closed
yuhuishi-convect opened this issue Nov 18, 2022 · 5 comments

Comments

@yuhuishi-convect
Copy link

yuhuishi-convect commented Nov 18, 2022

Expected Behavior

pandas is imported without error.

Current Behavior

Error message

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/__init__.py", line 48, in <module>
    from pandas.core.api import (
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/core/api.py", line 47, in <module>
    from pandas.core.groupby import (
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
    from pandas.core.groupby.generic import (
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/core/groupby/generic.py", line 76, in <module>
    from pandas.core.frame import DataFrame
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/core/frame.py", line 170, in <module>
    from pandas.core.generic import NDFrame
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/core/generic.py", line 147, in <module>
    from pandas.core.describe import describe_ndframe
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/core/describe.py", line 45, in <module>
    from pandas.io.formats.format import format_percentiles
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/io/formats/format.py", line 105, in <module>
    from pandas.io.common import (
  File "/layers/paketo-buildpacks_poetry-install/poetry-venv/auto-timeseries-xS3fZVNL-py3.11/lib/python3.11/site-packages/pandas/io/common.py", line 8, in <module>
    import bz2
  File "/layers/paketo-buildpacks_cpython/cpython/lib/python3.11/bz2.py", line 17, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'

Possible Solution

Use version 2.4 of the buildpack instead of 2.5
This looks like a problem with 2.5. I can build the image with 2.4 w/o such an issue.

Steps to Reproduce

  1. Clone the folder https://github.com/convect-ai/trac/tree/master/examples/time-series
  2. pack build time_series_forecasting -b gcr.io/paketo-buildpacks/python:2.5 --builder docker.io/paketobuildpacks/builder:base
  3. docker run --rm --entrypoint launcher time_series_forecasting poetry run python -c 'import pandas'

Motivations

@robdimsdale
Copy link
Member

Hi @yuhuishi-convect - sorry about this.

I'm not surprised to hear this because we aren't compiling the current version of python against the bz2 library. See paketo-buildpacks/cpython#468 for more details. We wanted to see what types of apps required bz2, and so it's actually really helpful to learn that Pandas apps often use it.

I think we should support Pandas, so we'll prioritize getting this fixed.

@robdimsdale
Copy link
Member

This should be resolved with: paketo-buildpacks/cpython#476

@robdimsdale
Copy link
Member

I've validated that this is fixed in CPython Buildpack v1.7.3.

We'll publish a new version of Python this week with the updated component buildpack

@robdimsdale
Copy link
Member

This should be fixed in Python Buildpack v2.6.0.

I'm going to close this, but please feel free to re-open if you continue to encounter this issue on v2.6.0

@yuhuishi-convect
Copy link
Author

Thanks for fixing that @robdimsdale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants