ImportError and CompileError from default, fresh conda installation

Hi everyone,

Thank you so much for this oustanding tool. We are new but very passionate users of PyMC and we have already been using it since a few months at UCL. However, since the last few weeks we are encountering some errors on MacOS from the default conda installation even in a fresh new env.

Specifically, after creating a new default env with

mamba create -c conda-forge -n mypymc "pymc>=5"

which successfully create an env with the following packages all from conda-forge:

Summary
  Package                                 Version  Build                    Channel                  Size
───────────────────────────────────────────────────────────────────────────────────────────────────────────
  Install:
───────────────────────────────────────────────────────────────────────────────────────────────────────────

  + arviz                                  0.20.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + atk-1.0                                2.38.0  h4bec284_2               conda-forge/osx-64     Cached
  + blas                                    2.122  openblas                 conda-forge/osx-64     Cached
  + blas-devel                              3.9.0  22_osx64_openblas        conda-forge/osx-64     Cached
  + brotli                                  1.1.0  h00291cd_2               conda-forge/osx-64     Cached
  + brotli-bin                              1.1.0  h00291cd_2               conda-forge/osx-64     Cached
  + bzip2                                   1.0.8  hfdf4475_7               conda-forge/osx-64     Cached
  + c-ares                                 1.33.1  h44e7173_0               conda-forge/osx-64     Cached
  + ca-certificates                     2024.8.30  h8857fd0_0               conda-forge/osx-64     Cached
  + cached-property                         1.5.2  hd8ed1ab_1               conda-forge/noarch     Cached
  + cached_property                         1.5.2  pyha770c72_1             conda-forge/noarch     Cached
  + cachetools                              5.5.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + cairo                                  1.18.0  h37bd5c4_3               conda-forge/osx-64     Cached
  + cctools_osx-64                         1010.6  h98e843e_1               conda-forge/osx-64     Cached
  + certifi                             2024.8.30  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + clang                                  17.0.6  default_he371ed4_7       conda-forge/osx-64     Cached
  + clang-17                               17.0.6  default_hb173f14_7       conda-forge/osx-64     Cached
  + clang_impl_osx-64                      17.0.6  h1af8efd_19              conda-forge/osx-64     Cached
  + clang_osx-64                           17.0.6  hb91bd55_19              conda-forge/osx-64     Cached
  + clangxx                                17.0.6  default_he371ed4_7       conda-forge/osx-64     Cached
  + clangxx_impl_osx-64                    17.0.6  hc3430b7_19              conda-forge/osx-64     Cached
  + clangxx_osx-64                         17.0.6  hb91bd55_19              conda-forge/osx-64     Cached
  + cloudpickle                             3.0.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + compiler-rt                            17.0.6  h1020d70_2               conda-forge/osx-64     Cached
  + compiler-rt_osx-64                     17.0.6  hf2b8a54_2               conda-forge/noarch     Cached
  + cons                                    0.4.6  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + contourpy                               1.3.0  py312hc5c4d5f_2          conda-forge/osx-64     Cached
  + cycler                                 0.12.1  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + etuples                                 0.3.9  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + expat                                   2.6.3  hac325c4_0               conda-forge/osx-64     Cached
  + filelock                               3.16.1  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + font-ttf-dejavu-sans-mono                2.37  hab24e00_0               conda-forge/noarch     Cached
  + font-ttf-inconsolata                    3.000  h77eed37_0               conda-forge/noarch     Cached
  + font-ttf-source-code-pro                2.038  h77eed37_0               conda-forge/noarch     Cached
  + font-ttf-ubuntu                          0.83  h77eed37_3               conda-forge/noarch     Cached
  + fontconfig                             2.14.2  h5bb23bf_0               conda-forge/osx-64     Cached
  + fonts-conda-ecosystem                       1  0                        conda-forge/noarch     Cached
  + fonts-conda-forge                           1  0                        conda-forge/noarch     Cached
  + fonttools                              4.54.1  py312hb553811_0          conda-forge/osx-64     Cached
  + freetype                               2.12.1  h60636b9_2               conda-forge/osx-64     Cached
  + fribidi                                1.0.10  hbcb3906_0               conda-forge/osx-64     Cached
  + gdk-pixbuf                            2.42.12  ha587570_0               conda-forge/osx-64     Cached
  + graphite2                              1.3.13  h73e2aa4_1003            conda-forge/osx-64     Cached
  + graphviz                               12.0.0  he14ced1_0               conda-forge/osx-64     Cached
  + gtk2                                  2.24.33  h2c15c3c_5               conda-forge/osx-64     Cached
  + gts                                     0.7.6  h53e17e3_4               conda-forge/osx-64     Cached
  + h5netcdf                                1.4.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + h5py                                   3.11.0  nompi_py312hfc94b03_102  conda-forge/osx-64     Cached
  + harfbuzz                                9.0.0  h098a298_1               conda-forge/osx-64     Cached
  + hdf5                                   1.14.3  nompi_h687a608_105       conda-forge/osx-64     Cached
  + icu                                      75.1  h120a0e1_0               conda-forge/osx-64     Cached
  + kiwisolver                              1.4.7  py312hc5c4d5f_0          conda-forge/osx-64     Cached
  + krb5                                   1.21.3  h37d8d59_0               conda-forge/osx-64     Cached
  + lcms2                                    2.16  ha2f27b4_0               conda-forge/osx-64     Cached
  + ld64_osx-64                             951.9  h38c89e5_1               conda-forge/osx-64     Cached
  + lerc                                    4.0.0  hb486fe8_0               conda-forge/osx-64     Cached
  + libaec                                  1.1.3  h73e2aa4_0               conda-forge/osx-64     Cached
  + libblas                                 3.9.0  22_osx64_openblas        conda-forge/osx-64     Cached
  + libbrotlicommon                         1.1.0  h00291cd_2               conda-forge/osx-64     Cached
  + libbrotlidec                            1.1.0  h00291cd_2               conda-forge/osx-64     Cached
  + libbrotlienc                            1.1.0  h00291cd_2               conda-forge/osx-64     Cached
  + libcblas                                3.9.0  22_osx64_openblas        conda-forge/osx-64     Cached
  + libclang-cpp17                         17.0.6  default_hb173f14_7       conda-forge/osx-64     Cached
  + libcurl                                8.10.1  h58e7537_0               conda-forge/osx-64     Cached
  + libcxx                                 19.1.1  hf95d169_0               conda-forge/osx-64     Cached
  + libcxx-devel                           17.0.6  h8f8a49f_6               conda-forge/osx-64     Cached
  + libdeflate                               1.22  h00291cd_0               conda-forge/osx-64     Cached
  + libedit                          3.1.20191231  h0678c8f_2               conda-forge/osx-64     Cached
  + libev                                    4.33  h10d778d_2               conda-forge/osx-64     Cached
  + libexpat                                2.6.3  hac325c4_0               conda-forge/osx-64     Cached
  + libffi                                  3.4.2  h0d85af4_5               conda-forge/osx-64     Cached
  + libgd                                   2.3.3  h2e77e4f_10              conda-forge/osx-64     Cached
  + libgfortran                             5.0.0  13_2_0_h97931a8_3        conda-forge/osx-64     Cached
  + libgfortran5                           13.2.0  h2873a65_3               conda-forge/osx-64     Cached
  + libglib                                2.82.1  h63bbcf2_0               conda-forge/osx-64     Cached
  + libhwloc                               2.11.1  default_h456cccd_1000    conda-forge/osx-64     Cached
  + libiconv                                 1.17  hd75f5a5_2               conda-forge/osx-64     Cached
  + libintl                                0.22.5  hdfe23c8_3               conda-forge/osx-64     Cached
  + libjpeg-turbo                           3.0.0  h0dc2134_1               conda-forge/osx-64     Cached
  + liblapack                               3.9.0  22_osx64_openblas        conda-forge/osx-64     Cached
  + liblapacke                              3.9.0  22_osx64_openblas        conda-forge/osx-64     Cached
  + libllvm17                              17.0.6  hbedff68_1               conda-forge/osx-64     Cached
  + libnghttp2                             1.58.0  h64cf6d3_1               conda-forge/osx-64     Cached
  + libopenblas                            0.3.27  openmp_h8869122_1        conda-forge/osx-64     Cached
  + libpng                                 1.6.44  h4b8f8c9_0               conda-forge/osx-64     Cached
  + librsvg                                2.58.4  h2682814_0               conda-forge/osx-64     Cached
  + libsqlite                              3.46.1  h4b8f8c9_0               conda-forge/osx-64     Cached
  + libssh2                                1.11.0  hd019ec5_0               conda-forge/osx-64     Cached
  + libtiff                                 4.7.0  h583c2ba_1               conda-forge/osx-64     Cached
  + libwebp-base                            1.4.0  h10d778d_0               conda-forge/osx-64     Cached
  + libxcb                                 1.17.0  hf1f96e2_0               conda-forge/osx-64     Cached
  + libxml2                                2.12.7  heaf3512_4               conda-forge/osx-64     Cached
  + libzlib                                 1.3.1  hd23fc13_2               conda-forge/osx-64     Cached
  + llvm-openmp                            19.1.0  h56322cc_0               conda-forge/osx-64     Cached
  + llvm-tools                             17.0.6  hbedff68_1               conda-forge/osx-64     Cached
  + logical-unification                     0.4.6  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + macosx_deployment_target_osx-64         10.13  hbc8f3bb_1               conda-forge/noarch     Cached
  + markdown-it-py                          3.0.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + matplotlib-base                         3.9.2  py312h30cc4df_1          conda-forge/osx-64     Cached
  + mdurl                                   0.1.2  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + minikanren                              1.0.3  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + mkl                                  2023.2.0  h54c2260_50500           conda-forge/osx-64     Cached
  + mkl-service                             2.4.0  py312h2402a68_1          conda-forge/osx-64     Cached
  + multipledispatch                        0.6.0  pyhd8ed1ab_1             conda-forge/noarch     Cached
  + munkres                                 1.1.4  pyh9f0ad1d_0             conda-forge/noarch     Cached
  + ncurses                                   6.5  hf036a51_1               conda-forge/osx-64     Cached
  + numpy                                  1.26.4  py312he3a82b2_0          conda-forge/osx-64     Cached
  + openblas                               0.3.27  openmp_hba01982_1        conda-forge/osx-64     Cached
  + openjpeg                                2.5.2  h7310d3a_0               conda-forge/osx-64     Cached
  + openssl                                 3.3.2  hd23fc13_0               conda-forge/osx-64     Cached
  + packaging                                24.1  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + pandas                                  2.2.3  py312h98e817e_1          conda-forge/osx-64     Cached
  + pango                                  1.54.0  h115fe74_2               conda-forge/osx-64     Cached
  + pcre2                                   10.44  h7634a1b_2               conda-forge/osx-64     Cached
  + pillow                                 10.4.0  py312h683ea77_1          conda-forge/osx-64     Cached
  + pip                                      24.2  pyh8b19718_1             conda-forge/noarch     Cached
  + pixman                                 0.43.4  h73e2aa4_0               conda-forge/osx-64     Cached
  + pthread-stubs                             0.4  h00291cd_1002            conda-forge/osx-64     Cached
  + pygments                               2.18.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + pymc                                   5.17.0  hd8ed1ab_0               conda-forge/noarch     Cached
  + pymc-base                              5.17.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + pyparsing                               3.1.4  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + pytensor                               2.25.5  py312h9592d4c_0          conda-forge/osx-64     Cached
  + pytensor-base                          2.25.5  py312h81f2e74_0          conda-forge/osx-64     Cached
  + python                                 3.12.7  h8f8b54e_0_cpython       conda-forge/osx-64     Cached
  + python-dateutil                         2.9.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + python-graphviz                        0.20.3  pyhe28f650_1             conda-forge/noarch     Cached
  + python-tzdata                          2024.2  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + python_abi                               3.12  5_cp312                  conda-forge/osx-64     Cached
  + pytz                                   2024.1  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + qhull                                  2020.2  h3c5361c_5               conda-forge/osx-64     Cached
  + readline                                  8.2  h9e318b2_1               conda-forge/osx-64     Cached
  + rich                                   13.9.2  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + scipy                                  1.14.1  py312he82a568_0          conda-forge/osx-64     Cached
  + setuptools                             75.1.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + sigtool                                 0.1.3  h88f4db0_0               conda-forge/osx-64     Cached
  + six                                    1.16.0  pyh6c4a22f_0             conda-forge/noarch     Cached
  + tapi                                 1300.6.5  h390ca13_0               conda-forge/osx-64     Cached
  + tbb                                 2021.13.0  h37c8870_0               conda-forge/osx-64     Cached
  + threadpoolctl                           3.5.0  pyhc1e730c_0             conda-forge/noarch     Cached
  + tk                                     8.6.13  h1abcd95_1               conda-forge/osx-64     Cached
  + toolz                                   1.0.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + typing-extensions                      4.12.2  hd8ed1ab_0               conda-forge/noarch     Cached
  + typing_extensions                      4.12.2  pyha770c72_0             conda-forge/noarch     Cached
  + tzdata                                  2024b  hc8b5060_0               conda-forge/noarch     Cached
  + wheel                                  0.44.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + xarray                               2024.9.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + xarray-einstats                         0.8.0  pyhd8ed1ab_0             conda-forge/noarch     Cached
  + xorg-libxau                            1.0.11  h00291cd_1               conda-forge/osx-64     Cached
  + xorg-libxdmcp                           1.1.5  h00291cd_0               conda-forge/osx-64     Cached
  + xz                                      5.2.6  h775f41a_0               conda-forge/osx-64     Cached
  + zlib                                    1.3.1  hd23fc13_2               conda-forge/osx-64     Cached
  + zstd                                    1.5.6  h915ae27_0               conda-forge/osx-64     Cached

  Summary:

  Install: 153 packages

  Total download: 0  B

───────────────────────────────────────────────────────────────────────────────────────────────────────────

Confirm changes: [Y/n] 
Preparing transaction: done
Verifying transaction: done
Executing transaction: / 
\ 
done
#
# To activate this environment, use
#
#     $ conda activate mypymc
#
# To deactivate an active environment, use
#
#     $ conda deactivate

PyMC ends up not working and throwing weird warnings. First, during import it throws the following WARNING which we have never had before and never on linux systems.

In [1]: import pymc as pm
WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

Next, PyMC fails to run with ImportErrors and CompileErrors:

In [2]: with pm.Model() as model:
   ...:     latent_p = pm.Uniform('p', lower=0, upper=1)
   ...:     x = pm.Binomial('x', n=100, p=latent_p, observed=20)
   ...: 
   ...: pm.model_to_graphviz(model)

You can find the C code in this temporary file: /var/folders/pf/lqt23xyj2kbcdc3fc0qghf10stfz88/T/pytensor_compilation_error_wzggj3yz
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/c/lazylinker_c.py:66
     65         if version != actual_version:
---> 66             raise ImportError(
     67                 "Version check of the existing lazylinker compiled file."
     68                 f" Looking for version {version}, but found {actual_version}. "
     69                 f"Extra debug information: force_compile={force_compile}, _need_reload={_need_reload}"
     70             )
     71 except ImportError:

ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.212, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/c/lazylinker_c.py:87
     86     if version != actual_version:
---> 87         raise ImportError(
     88             "Version check of the existing lazylinker compiled file."
     89             f" Looking for version {version}, but found {actual_version}. "
     90             f"Extra debug information: force_compile={force_compile}, _need_reload={_need_reload}"
     91         )
     92 except ImportError:
     93     # It is useless to try to compile if there isn't any
     94     # compiler!  But we still want to try to load it, in case
     95     # the cache was copied from another computer.

ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.212, but found None. Extra debug information: force_compile=False, _need_reload=True

During handling of the above exception, another exception occurred:

CompileError                              Traceback (most recent call last)
Cell In[2], line 5
      2     latent_p = pm.Uniform('p', lower=0, upper=1)
      3     x = pm.Binomial('x', n=100, p=latent_p, observed=20)
----> 5 pm.model_to_graphviz(model)

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pymc/model_graph.py:770, in model_to_graphviz(model, var_names, formatting, save, figsize, dpi, node_formatters, include_dim_lengths)
    766 model = pm.modelcontext(model)
    767 graph = ModelGraph(model)
    768 return make_graph(
    769     model.name,
--> 770     plates=graph.get_plates(var_names=var_names),
    771     edges=graph.edges(var_names=var_names),
    772     formatting=formatting,
    773     save=save,
    774     figsize=figsize,
    775     dpi=dpi,
    776     node_formatters=node_formatters,
    777     create_plate_label=create_plate_label_with_dim_length
    778     if include_dim_lengths
    779     else create_plate_label_without_dim_length,
    780 )

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pymc/model_graph.py:370, in ModelGraph.get_plates(self, var_names)
    363 # TODO: Evaluate all RV shapes at once
    364 #       This should help find discrepencies, and
    365 #       avoids unnecessary function compiles for determining labels.
    366 dim_lengths: dict[str, int] = {
    367     dim_name: fast_eval(value).item() for dim_name, value in self.model.dim_lengths.items()
    368 }
    369 var_shapes: dict[str, tuple[int, ...]] = {
--> 370     var_name: tuple(fast_eval(self.model[var_name].shape))
    371     for var_name in self.vars_to_plot(var_names)
    372 }
    374 for var_name in self.vars_to_plot(var_names):
    375     shape: tuple[int, ...] = var_shapes[var_name]

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pymc/model_graph.py:81, in fast_eval(var)
     80 def fast_eval(var):
---> 81     return function([], var, mode="FAST_COMPILE")()

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/compile/function/__init__.py:318, in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
    312     fn = orig_function(
    313         inputs, outputs, mode=mode, accept_inplace=accept_inplace, name=name
    314     )
    315 else:
    316     # note: pfunc will also call orig_function -- orig_function is
    317     #      a choke point that all compilation must pass through
--> 318     fn = pfunc(
    319         params=inputs,
    320         outputs=outputs,
    321         mode=mode,
    322         updates=updates,
    323         givens=givens,
    324         no_default_updates=no_default_updates,
    325         accept_inplace=accept_inplace,
    326         name=name,
    327         rebuild_strict=rebuild_strict,
    328         allow_input_downcast=allow_input_downcast,
    329         on_unused_input=on_unused_input,
    330         profile=profile,
    331         output_keys=output_keys,
    332     )
    333 return fn

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/compile/function/pfunc.py:465, in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys, fgraph)
    451     profile = ProfileStats(message=profile)
    453 inputs, cloned_outputs = construct_pfunc_ins_and_outs(
    454     params,
    455     outputs,
   (...)
    462     fgraph=fgraph,
    463 )
--> 465 return orig_function(
    466     inputs,
    467     cloned_outputs,
    468     mode,
    469     accept_inplace=accept_inplace,
    470     name=name,
    471     profile=profile,
    472     on_unused_input=on_unused_input,
    473     output_keys=output_keys,
    474     fgraph=fgraph,
    475 )

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/compile/function/types.py:1762, in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys, fgraph)
   1750     m = Maker(
   1751         inputs,
   1752         outputs,
   (...)
   1759         fgraph=fgraph,
   1760     )
   1761     with config.change_flags(compute_test_value="off"):
-> 1762         fn = m.create(defaults)
   1763 finally:
   1764     if profile and fn:

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/compile/function/types.py:1654, in FunctionMaker.create(self, input_storage, storage_map)
   1651 start_import_time = pytensor.link.c.cmodule.import_time
   1653 with config.change_flags(traceback__limit=config.traceback__compile_limit):
-> 1654     _fn, _i, _o = self.linker.make_thunk(
   1655         input_storage=input_storage_lists, storage_map=storage_map
   1656     )
   1658 end_linker = time.perf_counter()
   1660 linker_time = end_linker - start_linker

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/basic.py:245, in LocalLinker.make_thunk(self, input_storage, output_storage, storage_map, **kwargs)
    238 def make_thunk(
    239     self,
    240     input_storage: Optional["InputStorageType"] = None,
   (...)
    243     **kwargs,
    244 ) -> tuple["BasicThunkType", "InputStorageType", "OutputStorageType"]:
--> 245     return self.make_all(
    246         input_storage=input_storage,
    247         output_storage=output_storage,
    248         storage_map=storage_map,
    249     )[:3]

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/vm.py:1282, in VMLinker.make_all(self, profiler, input_storage, output_storage, storage_map)
   1279 else:
   1280     post_thunk_clear = None
-> 1282 vm = self.make_vm(
   1283     order,
   1284     thunks,
   1285     input_storage,
   1286     output_storage,
   1287     storage_map,
   1288     post_thunk_clear,
   1289     computed,
   1290     compute_map,
   1291     self.updated_vars,
   1292 )
   1294 vm.storage_map = storage_map
   1295 vm.compute_map = compute_map

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/vm.py:1010, in VMLinker.make_vm(self, nodes, thunks, input_storage, output_storage, storage_map, post_thunk_clear, computed, compute_map, updated_vars)
   1007 pre_call_clear = [storage_map[v] for v in self.no_recycling]
   1009 try:
-> 1010     from pytensor.link.c.cvm import CVM
   1011 except (MissingGXX, ImportError):
   1012     CVM = None

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/c/cvm.py:13
      9 if not config.cxx:
     10     raise MissingGXX(
     11         "lazylinker will not be imported if pytensor.config.cxx is not set."
     12     )
---> 13 from pytensor.link.c.lazylinker_c import CLazyLinker
     15 class CVM(CLazyLinker, VM):
     16     def __init__(self, fgraph, *args, **kwargs):

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/c/lazylinker_c.py:122
    119 loc.mkdir(exist_ok=True)
    121 args = GCC_compiler.compile_args()
--> 122 GCC_compiler.compile_str(dirname, code, location=loc, preargs=args)
    123 # Save version into the __init__.py file.
    124 init_py = loc / "__init__.py"

File ~/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/c/cmodule.py:2654, in GCC_compiler.compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
   2646                 print(
   2647                     "Check if package python-dev or python-devel is installed."
   2648                 )
   2650     # We replace '\n' by '. ' in the error message because when Python
   2651     # prints the exception, having '\n' in the text makes it more
   2652     # difficult to read.
   2653     # compile_stderr = compile_stderr.replace("\n", ". ")
-> 2654     raise CompileError(
   2655         f"Compilation failed (return status={status}):\n{' '.join(cmd)}\n{compile_stderr}"
   2656     )
   2657 elif config.cmodule__compilation_warning and compile_stderr:
   2658     # Print errors just below the command line.
   2659     print(compile_stderr)

CompileError: Compilation failed (return status=1):
/Users/zaccars/anaconda3/envs/mypymc/bin/clang++ -dynamiclib -g -Wno-c++11-narrowing -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC -undefined dynamic_lookup -I/Users/zaccars/anaconda3/envs/pymc/lib/python3.12/site-packages/numpy/core/include -I/Users/zaccars/anaconda3/envs/pymc/include/python3.12 -I/Users/zaccars/anaconda3/envs/pymc/lib/python3.12/site-packages/pytensor/link/c/c_code -L/Users/zaccars/anaconda3/envs/pymc/lib -fvisibility=hidden -o /Users/zaccars/.pytensor/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.12.7-64/lazylinker_ext/lazylinker_ext.so /Users/zaccars/.pytensor/compiledir_macOS-14.6.1-x86_64-i386-64bit-i386-3.12.7-64/lazylinker_ext/mod.cpp
dyld[91935]: Symbol not found: __ZNK4tapi2v119LinkerInterfaceFile28getPlatformsAndMinDeploymentEv
  Referenced from: <E33DCAC4-3116-3019-8003-432FB3E66FB4> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
  Expected in:     <9918D37F-F19F-30B9-B311-13829B79C3B0> /Users/zaccars/anaconda3/envs/mypymc/lib/libtapi.dylib
clang++: error: unable to execute command: Abort trap: 6
clang++: error: linker command failed due to signal (use -v to see invocation)

Can anyone please help fixing this please? We have also tried to re-install XCode and related command line tools. It is a new error and I am not sure where/when it started to happen but it seems to be occurring only on MacOS.

Thank you

Please see the discussion in this thread.