Having error running the pymc3 distribution


I am following this link https://docs.pymc.io/notebooks/dp_mix.html example 1. I copied the same code in the website, but on my computer, it runs with errors with the distribution line. How can I work that out?

with pm.Model() as model:
alpha = pm.Gamma(‘alpha’, 1., 1.)
beta = pm.Beta(‘beta’, 1., alpha, shape=K)
w = pm.Deterministic(‘w’, stick_breaking(beta))
tau = pm.Gamma(‘tau’, 1., 1., shape=K)
lambda_ = pm.Uniform(‘lambda’, 0, 5, shape=K)
mu = pm.Normal(‘mu’, 0, tau=lambda_ * tau, shape=K)
obs = pm.NormalMixture(‘obs’, w, mu, tau=lambda_ * tau,

with model:
trace = pm.sample(1000, random_seed=SEED)

pm.traceplot(trace, varnames=[‘alpha’]);

alpha = pm.Gamma(‘alpha’, 1., 1.)
File “C:\Python27\Lib\site-packages\pymc3\distributions\distribution.py”, line 41, in new
dist = cls.dist(*args, **kwargs)
File “C:\Python27\Lib\site-packages\pymc3\distributions\distribution.py”, line 52, in dist
dist.init(*args, **kwargs)
File “C:\Python27\Lib\site-packages\pymc3\distributions\continuous.py”, line 2097, in init
self.mean = alpha / beta
File “C:\Python27\Lib\site-packages\theano\tensor\var.py”, line 197, in truediv
return theano.tensor.basic.true_div(self, other)
File “C:\Python27\Lib\site-packages\theano\gof\op.py”, line 670, in call
File “C:\Python27\Lib\site-packages\theano\gof\op.py”, line 955, in make_thunk
File “C:\Python27\Lib\site-packages\theano\gof\op.py”, line 858, in make_c_thunk
File “C:\Python27\Lib\site-packages\theano\gof\cc.py”, line 1217, in make_thunk
File “C:\Python27\Lib\site-packages\theano\gof\cc.py”, line 1157, in compile
File “C:\Python27\Lib\site-packages\theano\gof\cc.py”, line 1620, in cthunk_factory
key=key, lnk=self, keep_lock=keep_lock)
File “C:\Python27\Lib\site-packages\theano\gof\cmodule.py”, line 1181, in module_from_key
module = lnk.compile_cmodule(location)
File “C:\Python27\Lib\site-packages\theano\gof\cc.py”, line 1523, in compile_cmodule
File “C:\Python27\Lib\site-packages\theano\gof\cmodule.py”, line 2388, in compile_str
(status, compile_stderr.replace(’\n’, '. ')))
Exception: ("Compilation failed (return status=1): In file included from C:/Program Files/mingw-w64/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/math.h:36,. from C:\Users\Administrator\Miniconda2\include/pyport.h:325,. from C:\Users\Administrator\Miniconda2\include/Python.h:61,. from

This looks like theano or gcc (or some core component) failed to compile/install correctly on your windows machine. Working with Python on windows is not something I am familiar with, but there should be others on this forum who might be able to diagnose this error.

In the meanwhile, I’d recommend trying to reinstall theano + gcc on windows in different ways.

Your traceback got cut prematurely, but I think that your problem is that you didn’t conda install libpython. You should follow these instructions to install theano on windows. I recommend you uninstall everything and start again from scratch, to avoid conflicting packages.

Another thing, pymc3 no longer supports python2. The last version that supported py2 was 3.6 (the current release) but we will release 3.7 very soon, with many fixes and new features, and you won’t be able to use it in Python 2.

1 Like