PyStan Import Error on Ubuntu

248 views Asked by At

I am trying out Pystan using a simple example. The code is

from pystan import stan from pystan import StanModel

# bernoulli model
model_code = """
    data {
      int<lower=0> N;
      int<lower=0,upper=1> y[N];
    }
    parameters {
      real<lower=0,upper=1> theta;
    }
    model {
      theta ~ beta(0.5, 0.5);  // Jeffreys' prior
      for (n in 1:N)
        y[n] ~ bernoulli(theta);
    }
"""
# using the model as above
data = dict(N=10, y=[0, 1, 0, 1, 0, 1, 0, 1, 1, 1])
sm = StanModel(model_code=model_code)
fit = sm.sampling(data=data)
print(fit)

And I get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-6-814d99e9c970> in <module>()
     19 # using the model as above
     20 data = dict(N=10, y=[0, 1, 0, 1, 0, 1, 0, 1, 1, 1])
---> 21 sm = StanModel(model_code=model_code)
     22 fit = sm.sampling(data=data)
     23 print(fit)

/home/yanwang/anaconda3/lib/python3.6/site-packages/pystan/model.py in __init__(self, file, charset, model_name, model_code, stanc_ret, boost_lib, eigen_lib, verbose, obfuscate_model_name, extra_compile_args)
    315                 os.dup2(orig_stderr, sys.stderr.fileno())
    316 
--> 317         self.module = load_module(self.module_name, lib_dir)
    318         self.module_filename = os.path.basename(self.module.__file__)
    319         # once the module is in memory, we no longer need the file on disk

/home/yanwang/anaconda3/lib/python3.6/site-packages/pystan/model.py in load_module(module_name, module_path)
     48         pyximport.install()
     49         sys.path.append(module_path)
---> 50         return __import__(module_name)
     51     else:
     52         import imp

ImportError: /tmp/tmpmesl4pvm/stanfit4anon_model_a4c8c0b8415be15f0e6878b909bb73da_2095873661089489367.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE

I suspect there is something wrong with some .so files on my system. Do you have ideas on what's wrong?

0

There are 0 answers