PyStan do not talk with C++ compiler

Hello everybody. Due to a forced reset of my MacBook, I had to reinstall all the packages I had and after many cautious attempts to make pystan work correctly I have to ask your help. The strange thing is that I am a newbie in Stan and first time I installed pystan I had no problem.

After I run

pystan.StanModel(model_code)

for any kind of model, something similar to this error appears:

clang-9: warning: -Wl,-export_dynamic: 'linker' input unused [-Wunused-command-line-argument]
In file included from /var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:696:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:
/Users/dario/opt/anaconda3/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: 
      "Using deprecated NumPy API, disable it with "          "#define
      NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with " \
 ^
In file included from /var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:699:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/py_var_context.hpp:12:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/src/stan/io/dump.hpp:6:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/lib/stan_math/stan/math/prim/mat.hpp:52:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/lib/stan_math/stan/math/prim/mat/err/is_cholesky_factor_corr.hpp:5:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/lib/stan_math/stan/math/prim/mat/err/is_cholesky_factor.hpp:6:
/Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/lib/stan_math/stan/math/prim/mat/err/is_lower_triangular.hpp:25:27: warning: 
      'ptr_fun<double, double>' is deprecated [-Wdeprecated-declarations]
  return y.unaryExpr(std::ptr_fun(internal::notNan))
                          ^
/Users/dario/opt/anaconda3/bin/../include/c++/v1/functional:1107:1: note: 
      'ptr_fun<double, double>' has been explicitly marked deprecated here
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
^
/Users/dario/opt/anaconda3/bin/../include/c++/v1/__config:972:39: note: 
      expanded from macro '_LIBCPP_DEPRECATED_IN_CXX11'
#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                      ^
/Users/dario/opt/anaconda3/bin/../include/c++/v1/__config:961:48: note: 
      expanded from macro '_LIBCPP_DEPRECATED'
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^
In file included from /var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:700:
/Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan_fit.hpp:841:12: warning: 
      'auto_ptr<stan::io::var_context>' is deprecated
      [-Wdeprecated-declarations]
      std::auto_ptr<stan::io::var_context> init_context_ptr;
           ^
/Users/dario/opt/anaconda3/bin/../include/c++/v1/memory:2130:28: note: 
      'auto_ptr<stan::io::var_context>' has been explicitly marked deprecated
      here
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr
                           ^
/Users/dario/opt/anaconda3/bin/../include/c++/v1/__config:972:39: note: 
      expanded from macro '_LIBCPP_DEPRECATED_IN_CXX11'
#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                      ^
/Users/dario/opt/anaconda3/bin/../include/c++/v1/__config:961:48: note: 
      expanded from macro '_LIBCPP_DEPRECATED'
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:9479:30: warning: 
      comparison of integers of different signs: 'Py_ssize_t' (aka 'long') and
      'std::__1::vector<std::__1::basic_string<char>,
      std::__1::allocator<std::__1::basic_string<char> > >::size_type'
      (aka 'unsigned long') [-Wsign-compare]
    __pyx_t_12 = ((__pyx_t_9 != __pyx_v_fitptr->param_names_oi().size()) != 0);
                   ~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:25498:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:25979:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:26101:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:26211:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:26326:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:26440:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:26562:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:26672:3: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
  0, /*tp_print*/
  ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:34370:5: warning: 
      'tp_print' is deprecated [-Wdeprecated-declarations]
    0,
    ^
/Users/dario/opt/anaconda3/include/python3.8/cpython/object.h:260:5: note: 
      'tp_print' has been explicitly marked deprecated here
    Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
    ^
/Users/dario/opt/anaconda3/include/python3.8/pyport.h:515:54: note: expanded
      from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
In file included from /var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:699:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/py_var_context.hpp:12:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/src/stan/io/dump.hpp:6:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/lib/stan_math/stan/math/prim/mat.hpp:336:
In file included from /Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/lib/stan_math/stan/math/prim/mat/prob/poisson_log_glm_log.hpp:5:
/Users/dario/opt/anaconda3/lib/python3.8/site-packages/pystan/stan/lib/stan_math/stan/math/prim/mat/prob/poisson_log_glm_lpmf.hpp:64:59: warning: 
      unused typedef 'T_alpha_val' [-Wunused-local-typedef]
      typename partials_return_type<T_alpha>::type>::type T_alpha_val;
                                                          ^
In file included from /var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258.cpp:702:
/var/folders/9s/18xn72c94xj8mjyt353t1vq40000gp/T/pystan_dxjfxwqu/anon_model_2f17157ac53ffe7ece2266df2e3d48aa.hpp:131:24: warning: 
      unused typedef 'local_scalar_t__' [-Wunused-local-typedef]
        typedef double local_scalar_t__;
                       ^
[I 20:33:03.606 NotebookApp] Saving file at /OneDrive - Politecnico di Milano/backup/DADS Polimi/WirtMed/advanced/02_cost_prescription_natural.ipynb
[W 20:33:03.607 NotebookApp] Notebook OneDrive - Politecnico di Milano/backup/DADS Polimi/WirtMed/advanced/02_cost_prescription_natural.ipynb is not trusted
15 warnings generated.
ld: warning: -pie being ignored. It is only used when linking a main executable
Process SpawnPoolWorker-1:
Traceback (most recent call last):
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
ModuleNotFoundError: No module named 'stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258'
Process SpawnPoolWorker-2:
Traceback (most recent call last):
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
ModuleNotFoundError: No module named 'stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258'
Process SpawnPoolWorker-3:
Traceback (most recent call last):
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
ModuleNotFoundError: No module named 'stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258'
Process SpawnPoolWorker-4:
Traceback (most recent call last):
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
  File "/Users/dario/opt/anaconda3/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
ModuleNotFoundError: No module named 'stanfit4anon_model_2f17157ac53ffe7ece2266df2e3d48aa_7221674845362347258'

I am not an expert of software compatibility and to the best of my knowledge nor in this forum neither in stakoverflow or similar such a problem seems to be happened. The repeated appearance of the warning ‘_LIBCPP_DEPRECATED_IN_CXX11’ makes me think that probably it is a problem related to the communication between pystan and C++ compiler. Can someone figure out what it is happening?

  • Operating System:macOS Catalina 10.15.7
  • Python Version: Python 3.8.3
  • PyStan Version: pystan 2.19.1.1
  • Compiler/Toolkit: anaconda Command line client (version 1.7.2)

The only strange thing that I noticed so far is that

% clang --version

> clang version 9.0.1 
> Target: x86_64-apple-darwin19.6.0
> Thread model: posix

while

%  ls /Users/dario/opt/anaconda3/bin | grep clang

> clang
> clang++
> clang-9
> clang-cl
> clang-cpp
> x86_64-apple-darwin13.4.0-clang
> x86_64-apple-darwin13.4.0-clang++

but I don’t know how to deal with it. Thank you in advance for any help.

PS Rstan seem to work without any issue!

Interesting. I’m not sure what the problem is. I wonder if it could be an anaconda or a Cython issue. Did you use anaconda before on macOS?

Yes, always user anaconda for anything without any problem. Even before the reset pystan was installed with anaconda and I found no issues

Perhaps this the same multiprocessing bug described here: PyStan throws error when running chains in parallel (n_jobs > 1)

1 Like

It works! Thank you so much, obviously I was focusing on the wrong issue. Shall I modify the title of the topic since it is misleading?

(For completeness, warnings related to LIBCPP_DEPRECATED_IN_CXX11 remain, but they seem to be only warnings indeed)

1 Like

Changing the title isn’t necessary. Glad you found a solution.