Unable to get PyStan working on a Mac

I have been trying to get PyStan working on my Mac, recently updated to BigSur (it was not working even before).

My understanding is there is an issue with the C++ libraries the porting is using. I have tried to get the most recent XCode without success, but have got a long list of warning/errors as previously shown here which bottom line error was " [`command ‘gcc’ failed with exit status 1".

I since then installed the HomeBrew GCC. HomeBrew path is already at the beginning of my chain, so the last thing I did is to create two exports as per the follow: export CC=gcc-10 and export CXX=g+±10.

The situation has improved, and the model is then built, but when moving forward with a fit=model.sampling() the following error is now thrown.

 >>> model=pystan.StanModel(model_code="parameters{real y;}model{target+=normal_lpdf(y|0,1);}", verbose=False)
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_8ab83a938e7c797d2f5fb91136fab3b8 NOW.
>>> fit=model.sampling()
Process SpawnPoolWorker-4:
Process SpawnPoolWorker-2:
Process SpawnPoolWorker-1:
Process SpawnPoolWorker-6:
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
ModuleNotFoundError: No module named 'stanfit4anon_model_8ab83a938e7c797d2f5fb91136fab3b8_5783747721866283390'
ModuleNotFoundError: No module named 'stanfit4anon_model_8ab83a938e7c797d2f5fb91136fab3b8_5783747721866283390'
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/pool.py", line 114, in worker
    task = get()
ModuleNotFoundError: No module named 'stanfit4anon_model_8ab83a938e7c797d2f5fb91136fab3b8_5783747721866283390'
  File "/Users/andreamoro/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/queues.py", line 358, in get
    return _ForkingPickler.loads(res)
ModuleNotFoundError: No module named 'stanfit4anon_model_8ab83a938e7c797d2f5fb91136fab3b8_5783747721866283390'

If you are reporting a bug (thank you!) please use the issue tracker (github.com/stan-dev/pystan/issues) instead of the forums.

code_to_run_your_model(if_applicable)
  • Operating System: Mac OsX Big Sur
  • Python Version: 3.8.6.4
  • PyStan Version
  • Compiler/Toolkit: Homebrew gcc 10.2.0

Hi, great that you had your compiler set up fixed.

See PyStan throws error when running chains in parallel (n_jobs > 1)

2 Likes