Compilation error in Pystan (macOS Mojave)

I’m trying to get pystan (2.18) working under Mojave and have found myself with the following dilemma. If I try to use the macOS gcc I get the following:

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
/var/folders/rn/5cyhvg_x591146y8khk9vqz40000gp/T/tmp8ku2bvdo/stanfit4logistic_regression_b34cbd6e4c4687ee64f335b5b2408384_7347898005404304860.cpp:675:10: fatal error: 'ios' file not found
#include "ios"
1 warning and 1 error generated.

I’ve run xcode-select --install. Here’s the gcc version info:

$ gcc --version
Configured with: --prefix=/Applications/ --with-gxx-include-dir=/Applications/
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/

If I use gcc (GCC 4.8.5) installed with Anaconda 3 (5.3.0), I get

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /Users/jhuggins/anaconda3/envs/stan/lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/include-fixed/syslimits.h:7:0,
                 from /Users/jhuggins/anaconda3/envs/stan/lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/include-fixed/limits.h:34,
                 from /Users/jhuggins/anaconda3/envs/stan/include/python3.6m/Python.h:11,
                 from /var/folders/rn/5cyhvg_x591146y8khk9vqz40000gp/T/tmp33mvc0fh/stanfit4logistic_regression_b34cbd6e4c4687ee64f335b5b2408384_8158677822526299729.cpp:57:
/Users/jhuggins/anaconda3/envs/stan/lib/gcc/x86_64-apple-darwin11.4.2/4.8.5/include-fixed/limits.h:168:61: fatal error: limits.h: No such file or directory
 #include_next <limits.h>  /* recurse down to the real one */

Open up Spotlight and find where the limits.h file lives. Then, you are going have to add that directory to the search path for system headers.


First, use pip version pip install pystan and try compiling again.

There seems to be similar problems with mojave

Run this (in pandas issue) and try again:


If that doesn’t work, then remove xcode and commandline tools and do the fresh install.

Run all these tests in fresh conda-env.

Install PyStan from source to a new conda env.

conda create -n stan_env python=3.7 numpy cython
conda activate stan_env

Then install from source (needs git, install with conda if not found; conda install git)

pip install git+
1 Like

Thank you, ahartikainen! Your posts here and on GitHub are the only reason I fixed this bug in my own build. Running macOS_SDK_headers_for_macOS_10.14.pkg was all that was required.

1 Like