Skip to content

[Python] Pyarrow fails to import liblz4 when installed with Conda #55467

Open

Description

@peanutfun

Describe the bug, including details regarding any error messages, version, and platform.

Importing pyarrow v26.0.1 on arm64 macOS results in an import error. The liblz4 library cannot be found. The error is not present in v25.0.1.

$ mamba create -n arr pyarrow
$ mamba run -n arr python -c "import pyarrow"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import pyarrow
  File "/Users/ldr.riedel/miniforge3/envs/arr/lib/python3.15/site-packages/pyarrow/__init__.py", line 59, in <module>
    from pyarrow.lib import (BuildInfo, CppBuildInfo, RuntimeInfo, set_timezone_db_path,
    ...<3 lines>...
                             io_thread_count, is_opentelemetry_enabled, set_io_thread_count)
ImportError: dlopen(/Users/ldr.riedel/miniforge3/envs/arr/lib/python3.15/site-packages/pyarrow/lib.cpython-315-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/lz4/lib/liblz4.1.dylib
  Referenced from: <0A53EA39-619E-3FD6-AAE0-1E15DBA7BD80> /Users/ldr.riedel/miniforge3/envs/arr/lib/libarrow.2600.1.0.dylib
  Reason: tried: '/opt/homebrew/opt/lz4/lib/liblz4.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/lz4/lib/liblz4.1.dylib' (no such file), '/opt/homebrew/opt/lz4/lib/liblz4.1.dylib' (nosuch file), '/usr/local/lib/liblz4.1.dylib' (no such file), '/usr/lib/liblz4.1.dylib' (no such file, not in dyld cache)

Component(s)

Python

Activity

  1. changed the title [-]Pyarrow fails to import libz4 when installed with Conda[/-] [+][Python] Pyarrow fails to import libz4 when installed with Conda[/+] on Nov 10, 2026
  2. AlenkaF commented on Nov 10, 2026

    @AlenkaF
    Member

    Thank you for the report!

    I have installed miniforge on my arm64 macOS (M1), created 3 separate envs with pyarrow 25.0.1, 26.0.0 and 26.0.1. and found discrepancies on how pyarrow is linked to lz4 via otool. Note I was not able to reproduce the failure because I have Homebrew's lz4 installed at that path.

    Using these commands

    mamba create -n pa-25-0-1 python=3.15 pyarrow=25.0.1
    mamba run -n pa-25-0-1 python -c "import pyarrow"
    prefix=~/miniforge3/envs/pa-25-0-1
    echo "== pa-25-0-1"; otool -L $prefix/lib/libarrow.*.dylib | grep lz4
    

    (and for pa-26-0-0, pa-26-0-1 respectively) I was able to get:

    pyarrow=25.0.1
    Linking lz4-c-1.10.0-hdca3b7d_2 (when creating the env)

    == pa-25-0-1
            @rpath/liblz4.1.dylib (compatibility version 1.0.0, current version 1.10.0)
            @rpath/liblz4.1.dylib (compatibility version 1.0.0, current version 1.10.0)
    

    pyarrow=26.0.0
    Linking lz4-c-1.10.0-hdca3b7d_2 (when creating the env)

    == pa-26-0-0
            @rpath/liblz4.1.dylib (compatibility version 1.0.0, current version 1.10.0)
            @rpath/liblz4.1.dylib (compatibility version 1.0.0, current version 1.10.0)
    

    pyarrow=26.0.1
    Linking lz4-c-1.10.0-hdca3b7d_2 (when creating the env)

    == pa-26-0-1
            /opt/homebrew/opt/lz4/lib/liblz4.1.dylib (compatibility version 1.0.0, current version 1.10.0)
            /opt/homebrew/opt/lz4/lib/liblz4.1.dylib (compatibility version 1.0.0, current version 1.10.0)
    

    In the last run the link is set to /opt/homebrew/opt/lz4/ instead of @rpath/liblz4.1.dylib. I think this belongs to conda-forge, cc @raulcd

  3. raulcd commented on Nov 10, 2026

    @raulcd
    Member

    I think this is related to:

    and:

    @h-vetinari should we apply this diff on the recipe:

    diff --git a/recipe/build.sh b/recipe/build.sh
    index b725cc07..2f924e25 100644
    --- a/recipe/build.sh
    +++ b/recipe/build.sh
    @@ -52,6 +52,11 @@ if [[ "${target_platform}" == "linux-aarch64" ]] || [[ "${target_platform}" == "
         export CMAKE_BUILD_PARALLEL_LEVEL=3
     fi
     
    +# native osx-arm64 runners have Homebrew in /opt/homebrew, which CMake searches by default
    +if [[ "${target_platform}" == "osx-arm64" ]]; then
    +    CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_IGNORE_PREFIX_PATH=/opt/homebrew"
    +fi
    +
     # IPO produces segfaults in the test suite on macOS x86-64
     if [[ "$target_platform" == "osx-64" ]]; then
         CMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF

    I think homebrew is messing up lz4 here for the latest published pyarrow on macOS arm64.

  4. changed the title [-][Python] Pyarrow fails to import libz4 when installed with Conda[/-] [+][Python] Pyarrow fails to import liblz4 when installed with Conda[/+] on Nov 10, 2026
  5. h-vetinari commented on Nov 10, 2026

    @h-vetinari
    Contributor

    Can you try again now that the builds from conda-forge/arrow-cpp-feedstock#2109 are online?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions