# Cannot get pymc to compile

**URL:** <https://discourse.pymc.io/t/cannot-get-pymc-to-compile/11631>\
**Category:** Questions\
**Tags:** development\_env\
**Created:** [March 16, 2023, 1:21pm UTC](https://discourse.pymc.io/t/cannot-get-pymc-to-compile/11631 "2023-03-16T13:21:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomKealy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tomkealy/32/3775_2.png) [@TomKealy](https://discourse.pymc.io/u/TomKealy)\
**Post date:** [March 16, 2023, 1:21pm UTC](https://discourse.pymc.io/t/cannot-get-pymc-to-compile/11631/1 "2023-03-16T13:21:24Z")

</div>

I have conda, and mamba installed, as well as Xcode on macOS Ventura 13.2.1 (Intel i7).

I can import pymc and this code shows I have version 4.1.5:

```auto
import pymc as pm

print(f"Running on PyMC v{pm. __version__ }")

```

When I try to run the code from the [introductory notebook](https://www.pymc.io/projects/docs/en/stable/learn/core_notebooks/pymc_overview.html#pymc-overview) however I get the following error:

```auto
ERROR (aesara.graph.opt): Optimization failure due to: constant_folding
ERROR (aesara.graph.opt): node: InplaceDimShuffle{}(TensorConstant{(1,) of 2})
ERROR (aesara.graph.opt): TRACEBACK:
ERROR (aesara.graph.opt): Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aesara/graph/opt.py", line 1861, in process_node
    replacements = lopt.transform(fgraph, node)
  File "/usr/local/lib/python3.9/site-packages/aesara/graph/opt.py", line 1066, in transform
    return self.fn(fgraph, node)
  File "/usr/local/lib/python3.9/site-packages/aesara/tensor/basic_opt.py", line 2784, in constant_folding
    thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/op.py", line 131, in make_thunk
    return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/op.py", line 96, in make_c_thunk
    outputs = cl.make_thunk(
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1198, in make_thunk
    cthunk, module, in_storage, out_storage, error_storage = self. __compile__ (
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1133, in __compile__
    thunk, module = self.cthunk_factory(
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1629, in cthunk_factory
    module = get_module_cache().module_from_key(key=key, lnk=self)
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/cmodule.py", line 1228, in module_from_key
    module = lnk.compile_cmodule(location)
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/basic.py", line 1538, in compile_cmodule
    module = c_compiler.compile_str(
  File "/usr/local/lib/python3.9/site-packages/aesara/link/c/cmodule.py", line 2639, in compile_str
    raise CompileError(
aesara.link.c.exceptions.CompileError: Compilation failed (return status=1):
/Users/tomkealy/mambaforge/envs/pymc_env/bin/clang++ -dynamiclib -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -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/usr/local/lib/python3.9/site-packages/numpy/core/include -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -I/usr/local/lib/python3.9/site-packages/aesara/link/c/c_code -L/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib -fvisibility=hidden -o /Users/tomkealy/.aesara/compiledir_macOS-13.2.1-x86_64-i386-64bit-i386-3.9.16-64/tmp2xj7s2yo/mba10987274f369529454d4a60996746c3927712a0b1b3928446a3c275151e2ee.so /Users/tomkealy/.aesara/compiledir_macOS-13.2.1-x86_64-i386-64bit-i386-3.9.16-64/tmp2xj7s2yo/mod.cpp
In file included from /Users/tomkealy/.aesara/compiledir_macOS-13.2.1-x86_64-i386-64bit-i386-3.9.16-64/tmp2xj7s2yo/mod.cpp:1:
In file included from /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9/Python.h:25:
/Users/tomkealy/mambaforge/envs/pymc_env/bin/../include/c++/v1/stdio.h:107:15: fatal error: 'stdio.h' file not found
#include_next <stdio.h>
              ^ ~~~~~~~~
1 error generated.

```

And I have no idea how to fix this.

Code to run the notebook:

```auto
import arviz as az
import matplotlib.pyplot as plt
import numpy as np

%config InlineBackend.figure_format = 'retina'
# Initialize random number generator
RANDOM_SEED = 8927
np.random.seed(RANDOM_SEED)
az.style.use("arviz-darkgrid")

# True parameter values
alpha, sigma = 1, 1
beta = [1, 2.5]

# Size of dataset
size = 100

# Predictor variable
X1 = np.random.randn(size)
X2 = np.random.randn(size) * 0.2

# Simulate outcome variable
Y = alpha + beta[0] * X1 + beta[1] * X2 + np.random.randn(size) * sigma

basic_model = pm.Model()

with basic_model:
    # Priors for unknown model parameters
    alpha = pm.Normal("alpha", mu=0, sigma=10)
    beta = pm.Normal("beta", mu=0, sigma=10, shape=2)
    sigma = pm.HalfNormal("sigma", sigma=1)

    # Expected value of outcome
    mu = alpha + beta[0] * X1 + beta[1] * X2

    # Likelihood (sampling distribution) of observations
    Y_obs = pm.Normal("Y_obs", mu=mu, sigma=sigma, observed=Y)

```

And I can’t get any further.

---

<div class="post-metadata">

**Author:** ![twiecki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/twiecki/32/6930_2.png) [@twiecki](https://discourse.pymc.io/u/twiecki)\
**Post date:** [March 16, 2023, 4:49pm UTC](https://discourse.pymc.io/t/cannot-get-pymc-to-compile/11631/2 "2023-03-16T16:49:48Z")

</div>

Have you tried a more recent PyMC (e.g. 5.1.2)?  
My hunch is still that xcode isn’t correctly/fully installed, I think I half-remember a similar problem and that was the fix.

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [March 17, 2023, 12:34am UTC](https://discourse.pymc.io/t/cannot-get-pymc-to-compile/11631/3 "2023-03-17T00:34:34Z")

</div>

This is definitely an Xcode problem. Related threads:

> [@Pytensor compilation error](https://discourse.pymc.io/t/pytensor-compilation-error/11047/8):
>
> I just got a new mac and ran into several compiler errors, including these missing standard C libraries. I had to do the following steps: I had to reinstall xcode-select (xcode-select --install, but in my case I also had to uninstall it first because I did a migration from an intel to an M1 system, so everything got messed up). BLAS doesn’t seem to grab the apple accelerate version that works on the ARM64 chips by default, so i had to do mamba install blas=\*=\*accelerate\* I added the loc…

> [@Unlinked header file in new PyMC5 install](https://discourse.pymc.io/t/unlinked-header-file-in-new-pymc5-install/11402/8):
>
> Several people have reported problems getting up and running on M1/2 macs, could you write down exactly what you changed and to what so there’s somewhere to point people to in the future?
