PyTensor fails to compile model after upgrading to mac OS 15.4

Is this a new conda env?

Have you tried that this?

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

Yes, new env, and have that.

Wow, so new env, you’ve followed the steps here, and none of this worked??

Yes, any idea on the error info above?

/.pytensor/compiledir_macOS-15.4-arm64-arm-64bit-arm-3.10.16-64/tmp_71um3ky/mod.cpp:496:9: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]
2025-04-10 17:10:25|CRITICAL|log:182|log_lines():   496 |         V5_stride0, V5_stride1, V5_stride2,

This doesn’t look like the error we were talking about. Can you share the code and exact steps that lead to this please? Otherwise it’s hard to help out

Try adding the following block to your .pytensorrc file:

[gcc]
cxxflags = -Wno-c++11-narrowing
2 Likes

Sorry, I’m unable to share the exact code… the full error messages are listed above, and it happened when I called nutpie.sample().

Thanks for the suggestion, where does .pytensorrc file locate?

Here

1 Like

" Try adding the following block to your .pytensorrc file:

[gcc]
cxxflags = -Wno-c++11-narrowing

"

This works for me!! Thank you, and thanks to everyone providing help!!

1 Like

I found the

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

works perfectly for me. But I also have code that I run on Mac and Linux (where I don’t have the problem) - so adding my solution below for when you are running code in Mac and Linux environments:

import platform

if platform.system() == 'Darwin': # you are on a mac, set up the correct compiler. If not, you are OK
    import pytensor
    pytensor.config.cxx = '/usr/bin/clang++'
1 Like

Legend, this works as a good temp fix for me.

This is exactly the case where you should be setting the config via .pytensorrc