Installation issues v5.9 macOS

Hi all,

I am having installation issues on macOS Sonoma (macbook pro m2) with the latest version of pymc (v5.9).

From a fresh conda environment created with:

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

As soon as I import pymc I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/marco.forgione/anaconda3/envs/bda/lib/python3.11/site-packages/pymc/__init__.py", line 47, in <module>
    __set_compiler_flags()
  File "/Users/marco.forgione/anaconda3/envs/bda/lib/python3.11/site-packages/pymc/__init__.py", line 30, in __set_compiler_flags
    import pytensor
  File "/Users/marco.forgione/anaconda3/envs/bda/lib/python3.11/site-packages/pytensor/__init__.py", line 119, in <module>
    from pytensor import scalar, tensor
  File "/Users/marco.forgione/anaconda3/envs/bda/lib/python3.11/site-packages/pytensor/tensor/__init__.py", line 105, in <module>
    from pytensor.tensor import sharedvar  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/marco.forgione/anaconda3/envs/bda/lib/python3.11/site-packages/pytensor/tensor/sharedvar.py", line 8, in <module>
    from pytensor.tensor.type import TensorType
  File "/Users/marco.forgione/anaconda3/envs/bda/lib/python3.11/site-packages/pytensor/tensor/type.py", line 746, in <module>
    pytensor.compile.register_view_op_c_code(
    ^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'pytensor' has no attribute 'compile' (most likely due to a circular import)

I othewise installed the package successfully on a x86 linux machine. Also, I previously had installed pymc v5.7.2 on my macbook with the same procedure and it used to work.

Are you installing x86 (with MKL et al) or Apple Silicon (with Accelerate et al) ?

Not sure I get your question. I installed on a Macbook Pro M2, thus Silicon architecture and I got the error. I also installed on a x86 linux machine and everything was fine there.

In both cases, I created a fresh conda environment with the command

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

as per the official documentation on the pymc website.

You can try with accelerate (Performance tip if you're on ARM64 (Apple's M1/M2 chips): Install accelerate):

conda create -c conda-forge -n pymc_env "pymc>=5" "libblas=*=*accelerate"
2 Likes

Yep, just curious in case (like me) you’re stubbornly persisting with x86 :smiley:

Well worth using ARM and explicitly requiring accelerate - as Thomas suggests

Works on my macbook silicon, thanks!

1 Like

I don’t have any specific requirements; I just use PyMC for teaching Bayesian data analysis to undergrads and try to ensure that we don’t spend the first lecture troubleshooting installation issues across all platforms. :wink:

1 Like

Can you mark my reply as the answer so that others can see that it’s solved?

Hi. I’m facing similar issues: M2Pro with Sonoma. I tried this, but in trying to install theano or theano-pymc I run into conflicts with my python version (3.11).

Is there a particular python version you’d recommend? pymc_env kept my own.

Thanks!

Which installation instructions are you following?

I have tried the instructions here and both versions of

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

and

conda create -c conda-forge -n pymc_env "pymc>=5" "libblas=*=*accelerate"

They seem to work fine, but things break when I try to install theano I get these messages with mamba:

(sorry if this is too crude, I’m too much of a noob if that’s not obvious already)

Thanks!

PyMC does not use theano these days but pytensor which is installed automatically with PyMC. Most of the old theano/theano.tensor code should work similarly as pytensor/pytensor.tensor

To expand on the above - don’t install Theano. You don’t need it. Just follow the instructions on the pymc website.

1 Like

Got it. Long story short, I’m starting with probabilistic programing using Martin et al ‘Bayesian Modeling’, which is based on PyMC 3, but their env is not compatible with my Mac. Took me a while to figure all out. I’m starting with PyMC 5 and then will go back to the book. Thanks!

That book just came out in its 3rd revision which uses PyMC 5.

Which would explain the sudden price drop of the book I got! I just cloned their repo with the updated code, which should make everything easier.

Thanks all for your comments.

2 Likes