Problems with installation of pymc after xcode update on mac

Hello,

After updating xcode on my macbook pro m2, pymc stopped working. I tried with a fresh install:

   conda create -c conda-forge -n pymc_env "pymc>=5"
   conda activate pymc_env

Now, a simple pymc code like:

import pymc as pm
import numpy as np

RANDOM_SEED = 8927
rng = np.random.default_rng(RANDOM_SEED)

with pm.Model() as model:
    mu = pm.Normal("mu", mu=0, sigma=1)
    obs = pm.Normal("obs", mu=mu, sigma=1, observed=rng.standard_normal(100))

    idata = pm.sample(2000)

gives me the following warning + error:

WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: ExpandDims{axis=0}(1) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1909, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py”, line 1122, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/link/c/op.py”, line 119, in make_thunk

clang++: error: unable to execute command: Abort trap: 6 clang++: error: linker command failed due to signal (use -v to see invocation)

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings

You can find the C code in this temporary file: /var/folders/w7/h67z1rn941j1p0m51k08d9xc0000gp/T/pytensor_compilation_error_mh9wt315

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: ExpandDims{axis=0}(1) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1909, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py”, line 1122, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/link/c/op.py”, line 119, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling)

clang++: error: unable to execute command: Abort trap: 6 clang++: error: linker command failed due to signal (use -v to see invocation)

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings

You can find the C code in this temporary file: /var/folders/w7/h67z1rn941j1p0m51k08d9xc0000gp/T/pytensor_compilation_error_xrwrb7xq

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: ExpandDims{axis=0}(1) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1909, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py”, line 1122, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/link/c/op.py”, line 119, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling)

clang++: error: unable to execute command: Abort trap: 6 clang++: error: linker command failed due to signal (use -v to see invocation)

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings

You can find the C code in this temporary file: /var/folders/w7/h67z1rn941j1p0m51k08d9xc0000gp/T/pytensor_compilation_error_ofeuhbkn

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: ExpandDims{axis=0}(1) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1909, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py”, line 1122, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/link/c/op.py”, line 119, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling)

clang++: error: unable to execute command: Abort trap: 6 clang++: error: linker command failed due to signal (use -v to see invocation)

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings

You can find the C code in this temporary file: /var/folders/w7/h67z1rn941j1p0m51k08d9xc0000gp/T/pytensor_compilation_error_f8nj0p8b

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: ExpandDims{axis=0}(1) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1909, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py”, line 1122, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/link/c/op.py”, line 119, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling)

clang++: error: unable to execute command: Abort trap: 6 clang++: error: linker command failed due to signal (use -v to see invocation)

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings

You can find the C code in this temporary file: /var/folders/w7/h67z1rn941j1p0m51k08d9xc0000gp/T/pytensor_compilation_error_lg28oyur

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: ExpandDims{axis=0}(1) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1909, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py”, line 1122, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/link/c/op.py”, line 119, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling)

clang++: error: unable to execute command: Abort trap: 6 clang++: error: linker command failed due to signal (use -v to see invocation)

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings

You can find the C code in this temporary file: /var/folders/w7/h67z1rn941j1p0m51k08d9xc0000gp/T/pytensor_compilation_error_pcx2r6_r

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: Cast{float64}(0) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1909, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/graph/rewriting/basic.py”, line 1081, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/tensor/rewriting/basic.py”, line 1122, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/Users/marco.forgione/anaconda3/envs/pymc_env/lib/python3.12/site-packages/pytensor/link/c/op.py”, line 119, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling)

clang++: error: unable to execute command: Abort trap: 6 clang++: error: linker command failed due to signal (use -v to see invocation)

A lot of us are having issues with the new macOS update All models broken after MacOS Sequoia update. A few workaround were proposed here: Environment not working anymore on macos.

Maybe I was lucky. I only updated my Xcode to version 15.4 and I don’t need to manually setting the clang++ path in Python file. Here was what I did: Environment not working anymore on macos - #21 by Duc_Quang_Nguyen

Otherwise, it seemed for anyone else updated macOS (and Xcode to 16.0), setting clang++ path is the solution

1 Like

Thanks @Duc_Quang_Nguyen,

For the moment I tried the fix:

pytensor.config.cxx = ''

in my python code and it works (might be slower, but I don’t need performance at the moment)

That will disable C compilation al together. If not using JAX/Numba backends, it will default to python only

This works for me, with performance back to normal:

import pytensor
pytensor.config.cxx = "/usr/bin/clang++"

Anybody knows how to make this “permanent”?

You can set configurations in a .pytensorrc file. See here for details.

1 Like

On my Mac with the latest OS update, I can get it to work with:

conda create -n pymc_test python=3.12 -y

Activate then

pip install 'pymc>=5.16'

and finally

conda install -c conda-forge libopenblas blas -y