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.
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
                Tensorflow tries to import PyArrow which depends on Protobuf and there is something wrong with Protobuf build for macOS. Here is somewhat similar PyArrow issue. Another related issue.
Downgrade to Tensorflow 2.19.x for now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With