[Python] import tensorflow statement crashes or hangs on macOS

Discussão em 'Python' iniciado por Stack, Agosto 23, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following Python statement, which I cannot execute in Jupyter Notebook or Python REPL:

    import tensorflow


    Python 3.11.10 (main, Sep 20 2024, 14:23:57) [Clang 16.0.0 (clang-1600.0.26.3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow


    On a console, you see the following thread locking error crashing the interpreter:

    libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument


    When run in a Jupyter Notebook, it will cause the kernel to hang indefinitely.

    • What causes this?
    • How to make it run?

    Python 3.11. Tensorflow 2.20.0. Pyarrow 21.0.0. macOS ARM.

    Related earlier question.

    Below is the traceback of python -vvv -c "import tensorflow"

    # trying /Users/moo/.pyenv/versions/3.11.10/lib/python3.11/lib-dynload/pyarrow.py
    # trying /Users/moo/.pyenv/versions/3.11.10/lib/python3.11/lib-dynload/pyarrow.pyc
    # /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/__pycache__/__init__.cpython-311.pyc matches /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/__init__.py
    # code object from '/Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/__pycache__/__init__.cpython-311.pyc'
    # trying /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/_generated_version.cpython-311-darwin.so
    # trying /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/_generated_version.abi3.so
    # trying /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/_generated_version.so
    # trying /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/_generated_version.py
    # /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/__pycache__/_generated_version.cpython-311.pyc matches /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/_generated_version.py
    # code object from '/Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/__pycache__/_generated_version.cpython-311.pyc'
    import 'pyarrow._generated_version' # <_frozen_importlib_external.SourceFileLoader object at 0x3113025d0>
    # trying /Users/moo/code/predictor2/.venv/lib/python3.11/site-packages/pyarrow/lib.cpython-311-darwin.so
    libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument

    Continue reading...

Compartilhe esta Página