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

BUG: pandas incompatible with Python installations lacking bzip2 headers #53857

Closed
3 tasks done
MilesCranmer opened this issue Jun 26, 2023 · 1 comment · Fixed by #53858
Closed
3 tasks done

BUG: pandas incompatible with Python installations lacking bzip2 headers #53857

MilesCranmer opened this issue Jun 26, 2023 · 1 comment · Fixed by #53858
Labels
Compat pandas objects compatability with Numpy or Python functions IO Data IO issues that don't fit into a more specific label

Comments

@MilesCranmer
Copy link
Contributor

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

Issue Description

On some Python installations, the libbzip2 headers are not compiled into Python. This is also true on some lightweight Python binaries, including (recently) several used by GitHub actions. It does not make much sense for pandas to require bz2 if one is not doing bzip compression, so I think this import should be safely skipped if not available.

You can see several of the GitHub actions for PySR are now failing due to a pandas import: https://github.com/MilesCranmer/PySR/actions/runs/5376798563, despite bzip2 compression never being used in the unittests.


Using /Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages
Finished processing dependencies for pysr==0.14.2
Traceback (most recent call last):
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/Users/runner/work/PySR/PySR/pysr/__init__.py", line 3, in <module>
    from .sr import (
  File "/Users/runner/work/PySR/PySR/pysr/sr.py", line 7, in <module>
    import pandas as pd
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/__init__.py", line 50, in <module>
    from pandas.core.api import (
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/core/api.py", line 48, in <module>
    from pandas.core.groupby import (
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
    from pandas.core.groupby.generic import (
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 73, in <module>
    from pandas.core.frame import DataFrame
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/core/frame.py", line 129, in <module>
    from pandas.core import (
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/core/generic.py", line 122, in <module>
    from pandas.core.describe import describe_ndframe
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/core/describe.py", line 39, in <module>
    from pandas.io.formats.format import format_percentiles
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/io/formats/format.py", line 99, in <module>
    from pandas.io.common import stringify_path
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pandas/io/common.py", line 4, in <module>
    import bz2
  File "/Users/runner/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/bz2.py", line 19, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
Error: Process completed with exit code 1.

I will submit a PR to fix this shortly.

Expected Behavior

N/A

Installed Versions

N/A

@MilesCranmer MilesCranmer added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 26, 2023
@MilesCranmer
Copy link
Contributor Author

Fixed by #53858

@lithomas1 lithomas1 added Compat pandas objects compatability with Numpy or Python functions IO Data IO issues that don't fit into a more specific label and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants