Error in the excution

I am using pymc3 for bayesian model averaging. When I run the model I get this warning “module ‘numpy’ has no attribute ‘bool’”. I upgrade and downgrade the packages and the same problem persist. Please anyone has an idea about the solution of this problem?

Sounds like a numpy issue rather than pymc / pymc3, per the full error printout:

np.bool
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

As the error message shown by @jonsedar says, this is functionality that was present in an old version of numpy and is no longer supported. It is strongly recommended that you install the current version of PyMC (instructions here) if you can.

1 Like

Thank you, it starts to work. But, then, I receive this WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [alpha, beta, sigma].

What platform are you on? Did you follow the installation instructions and install PyMC in a fresh environment? What is the output of conda list?

I am using spyder. Yes I followed all the instrucyions

Windows? And what does conda list show?

Windows 11.
conda list shows a lot of packages

Yes. Can you cut and paste the list here? It would help to diagnose what is going on with your installation.

conda list result:

output

packages in environment at C:\Users\Ossama\anaconda3\envs\pymc_env:

Name Version Build Channel

alabaster 0.7.13 pypi_0 pypi
arrow 1.3.0 pypi_0 pypi
arviz 0.16.1 pyhd8ed1ab_1 conda-forge
astroid 2.15.8 pypi_0 pypi
asttokens 2.4.0 pypi_0 pypi
atomicwrites 1.4.1 pypi_0 pypi
attrs 23.1.0 pypi_0 pypi
autopep8 2.0.4 pypi_0 pypi
babel 2.13.0 pypi_0 pypi
backcall 0.2.0 pypi_0 pypi
bcrypt 4.0.1 pypi_0 pypi
beautifulsoup4 4.12.2 pypi_0 pypi
binaryornot 0.4.4 pypi_0 pypi
black 23.10.0 pypi_0 pypi
bleach 6.1.0 pypi_0 pypi
brotli 1.1.0 hcfcfb64_1 conda-forge
brotli-bin 1.1.0 hcfcfb64_1 conda-forge
bzip2 1.0.8 h8ffe710_4 conda-forge
ca-certificates 2023.7.22 h56e8100_0 conda-forge
cached-property 1.5.2 hd8ed1ab_1 conda-forge
cached_property 1.5.2 pyha770c72_1 conda-forge
cachetools 5.3.1 pyhd8ed1ab_0 conda-forge
cairo 1.18.0 h1fef639_0 conda-forge
certifi 2023.7.22 pyhd8ed1ab_0 conda-forge
cffi 1.16.0 pypi_0 pypi
chardet 5.2.0 pypi_0 pypi
charset-normalizer 3.3.1 pypi_0 pypi
click 8.1.7 pypi_0 pypi
cloudpickle 3.0.0 pyhd8ed1ab_0 conda-forge
colorama 0.4.6 pypi_0 pypi
comm 0.1.4 pypi_0 pypi
cons 0.4.6 pyhd8ed1ab_0 conda-forge
contourpy 1.1.1 py311h005e61a_1 conda-forge
cookiecutter 2.4.0 pypi_0 pypi
cryptography 41.0.4 pypi_0 pypi
cycler 0.12.1 pyhd8ed1ab_0 conda-forge
debugpy 1.8.0 pypi_0 pypi
decorator 5.1.1 pypi_0 pypi
defusedxml 0.7.1 pypi_0 pypi
diff-match-patch 20230430 pypi_0 pypi
dill 0.3.7 pypi_0 pypi
docstring-to-markdown 0.13 pypi_0 pypi
docutils 0.20.1 pypi_0 pypi
etuples 0.3.9 pyhd8ed1ab_0 conda-forge
executing 2.0.0 pypi_0 pypi
expat 2.5.0 h63175ca_1 conda-forge
fastjsonschema 2.18.1 pypi_0 pypi
fastprogress 1.0.3 pyhd8ed1ab_0 conda-forge
filelock 3.12.4 pyhd8ed1ab_0 conda-forge
flake8 6.0.0 pypi_0 pypi
font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge
font-ttf-inconsolata 3.000 h77eed37_0 conda-forge
font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge
font-ttf-ubuntu 0.83 hab24e00_0 conda-forge
fontconfig 2.14.2 hbde0cde_0 conda-forge
fonts-conda-ecosystem 1 0 conda-forge
fonts-conda-forge 1 0 conda-forge
fonttools 4.43.1 py311ha68e1ae_0 conda-forge
freetype 2.12.1 hdaf720e_2 conda-forge
fribidi 1.0.10 h8d14728_0 conda-forge
getopt-win32 0.1 hcfcfb64_1 conda-forge
gettext 0.21.1 h5728263_0 conda-forge
graphite2 1.3.13 1000 conda-forge
graphviz 8.1.0 h51cb2cd_0 conda-forge
gts 0.7.6 h6b5321d_4 conda-forge
h5netcdf 1.2.0 pyhd8ed1ab_0 conda-forge
h5py 3.10.0 nompi_py311h0d04526_100 conda-forge
harfbuzz 8.2.1 h7ab893a_0 conda-forge
hdf5 1.14.2 nompi_h73e8ff5_100 conda-forge
icu 73.2 h63175ca_0 conda-forge
idna 3.4 pypi_0 pypi
imagesize 1.4.1 pypi_0 pypi
importlib-metadata 6.8.0 pypi_0 pypi
inflection 0.5.1 pypi_0 pypi
intel-openmp 2023.2.0 h57928b3_50496 conda-forge
intervaltree 3.1.0 pypi_0 pypi
ipykernel 6.25.2 pypi_0 pypi
ipython 8.16.1 pypi_0 pypi
ipython-genutils 0.2.0 pypi_0 pypi
isort 5.12.0 pypi_0 pypi
jaraco-classes 3.3.0 pypi_0 pypi
jedi 0.18.2 pypi_0 pypi
jellyfish 1.0.1 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
jsonschema 4.19.1 pypi_0 pypi
jsonschema-specifications 2023.7.1 pypi_0 pypi
jupyter-client 8.4.0 pypi_0 pypi
jupyter-core 5.4.0 pypi_0 pypi
jupyterlab-pygments 0.2.2 pypi_0 pypi
keyring 24.2.0 pypi_0 pypi
kiwisolver 1.4.5 py311h005e61a_1 conda-forge
krb5 1.21.2 heb0366b_0 conda-forge
lazy-object-proxy 1.9.0 pypi_0 pypi
lcms2 2.15 h67d730c_3 conda-forge
lerc 4.0.0 h63175ca_0 conda-forge
libaec 1.1.2 h63175ca_1 conda-forge
libblas 3.9.0 19_win64_mkl conda-forge
libbrotlicommon 1.1.0 hcfcfb64_1 conda-forge
libbrotlidec 1.1.0 hcfcfb64_1 conda-forge
libbrotlienc 1.1.0 hcfcfb64_1 conda-forge
libcblas 3.9.0 19_win64_mkl conda-forge
libcurl 8.4.0 hd5e4a3a_0 conda-forge
libdeflate 1.19 hcfcfb64_0 conda-forge
libexpat 2.5.0 h63175ca_1 conda-forge
libffi 3.4.2 h8ffe710_5 conda-forge
libgd 2.3.3 h312136b_9 conda-forge
libglib 2.78.0 he8f3873_0 conda-forge
libhwloc 2.9.3 default_haede6df_1009 conda-forge
libiconv 1.17 h8ffe710_0 conda-forge
libjpeg-turbo 3.0.0 hcfcfb64_1 conda-forge
liblapack 3.9.0 19_win64_mkl conda-forge
libpng 1.6.39 h19919ed_0 conda-forge
libsqlite 3.43.2 hcfcfb64_0 conda-forge
libssh2 1.11.0 h7dfc565_0 conda-forge
libtiff 4.6.0 h6e2ebb7_2 conda-forge
libwebp 1.3.2 hcfcfb64_1 conda-forge
libwebp-base 1.3.2 hcfcfb64_0 conda-forge
libxcb 1.15 hcd874cb_0 conda-forge
libxml2 2.11.5 hc3477c8_1 conda-forge
libzlib 1.2.13 hcfcfb64_5 conda-forge
logical-unification 0.4.6 pyhd8ed1ab_0 conda-forge
m2w64-gcc-libgfortran 5.3.0 6 conda-forge
m2w64-gcc-libs 5.3.0 7 conda-forge
m2w64-gcc-libs-core 5.3.0 7 conda-forge
m2w64-gmp 6.1.0 2 conda-forge
m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge
markdown-it-py 3.0.0 pypi_0 pypi
markupsafe 2.1.3 pypi_0 pypi
matplotlib-base 3.8.0 py311h6e989c2_2 conda-forge
matplotlib-inline 0.1.6 pypi_0 pypi
mccabe 0.7.0 pypi_0 pypi
mdurl 0.1.2 pypi_0 pypi
minikanren 1.0.3 pyhd8ed1ab_0 conda-forge
mistune 3.0.2 pypi_0 pypi
mkl 2023.2.0 h6a75c08_50496 conda-forge
more-itertools 10.1.0 pypi_0 pypi
msys2-conda-epoch 20160418 1 conda-forge
multipledispatch 0.6.0 py_0 conda-forge
munkres 1.1.4 pyh9f0ad1d_0 conda-forge
mypy-extensions 1.0.0 pypi_0 pypi
nbclient 0.8.0 pypi_0 pypi
nbconvert 7.9.2 pypi_0 pypi
nbformat 5.9.2 pypi_0 pypi
nest-asyncio 1.5.8 pypi_0 pypi
numpy 1.25.2 py311h0b4df5a_0 conda-forge
numpydoc 1.6.0 pypi_0 pypi
openjpeg 2.5.0 h3d672ee_3 conda-forge
openssl 3.1.3 hcfcfb64_0 conda-forge
packaging 23.2 pyhd8ed1ab_0 conda-forge
pandas 2.1.1 py311hf63dbb6_1 conda-forge
pandocfilters 1.5.0 pypi_0 pypi
pango 1.50.14 h07c897b_2 conda-forge
paramiko 3.3.1 pypi_0 pypi
parso 0.8.3 pypi_0 pypi
pathspec 0.11.2 pypi_0 pypi
pcre2 10.40 h17e33f8_0 conda-forge
pexpect 4.8.0 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pillow 10.1.0 py311h4dd8a23_0 conda-forge
pip 23.3.1 pyhd8ed1ab_0 conda-forge
pixman 0.42.2 h63175ca_0 conda-forge
platformdirs 3.11.0 pypi_0 pypi
pluggy 1.3.0 pypi_0 pypi
prompt-toolkit 3.0.39 pypi_0 pypi
psutil 5.9.6 pypi_0 pypi
pthread-stubs 0.4 hcd874cb_1001 conda-forge
pthreads-win32 2.9.1 hfa6e2cd_3 conda-forge
ptyprocess 0.7.0 pypi_0 pypi
pure-eval 0.2.2 pypi_0 pypi
pycodestyle 2.10.0 pypi_0 pypi
pycparser 2.21 pypi_0 pypi
pydocstyle 6.3.0 pypi_0 pypi
pyflakes 3.0.1 pypi_0 pypi
pygments 2.16.1 pypi_0 pypi
pylint 2.17.7 pypi_0 pypi
pylint-venv 3.0.2 pypi_0 pypi
pyls-spyder 0.4.0 pypi_0 pypi
pymc 5.9.0 hd8ed1ab_0 conda-forge
pymc-base 5.9.0 pyhd8ed1ab_0 conda-forge
pynacl 1.5.0 pypi_0 pypi
pyparsing 3.1.1 pyhd8ed1ab_0 conda-forge
pyqt5 5.15.10 pypi_0 pypi
pyqt5-qt5 5.15.2 pypi_0 pypi
pyqt5-sip 12.13.0 pypi_0 pypi
pyqtwebengine 5.15.6 pypi_0 pypi
pyqtwebengine-qt5 5.15.2 pypi_0 pypi
pytensor 2.13.1 py311hf62ec03_0
pytensor-base 2.17.3 py311hf63dbb6_0 conda-forge
python 3.11.6 h2628c8c_0_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python-graphviz 0.20.1 pyh22cad53_0 conda-forge
python-lsp-black 1.3.0 pypi_0 pypi
python-lsp-jsonrpc 1.1.2 pypi_0 pypi
python-lsp-server 1.7.4 pypi_0 pypi
python-slugify 8.0.1 pypi_0 pypi
python-tzdata 2023.3 pyhd8ed1ab_0 conda-forge
python_abi 3.11 4_cp311 conda-forge
pytoolconfig 1.2.6 pypi_0 pypi
pytz 2023.3.post1 pyhd8ed1ab_0 conda-forge
pywin32 306 pypi_0 pypi
pywin32-ctypes 0.2.2 pypi_0 pypi
pyyaml 6.0.1 pypi_0 pypi
pyzmq 25.1.1 pypi_0 pypi
qdarkstyle 3.1 pypi_0 pypi
qstylizer 0.2.2 pypi_0 pypi
qtawesome 1.2.3 pypi_0 pypi
qtconsole 5.4.4 pypi_0 pypi
qtpy 2.4.0 pypi_0 pypi
referencing 0.30.2 pypi_0 pypi
requests 2.31.0 pypi_0 pypi
rich 13.6.0 pypi_0 pypi
rope 1.10.0 pypi_0 pypi
rpds-py 0.10.6 pypi_0 pypi
rtree 1.1.0 pypi_0 pypi
scipy 1.11.3 py311h0b4df5a_1 conda-forge
setuptools 68.2.2 pyhd8ed1ab_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
snowballstemmer 2.2.0 pypi_0 pypi
sortedcontainers 2.4.0 pypi_0 pypi
soupsieve 2.5 pypi_0 pypi
sphinx 7.2.6 pypi_0 pypi
sphinxcontrib-applehelp 1.0.7 pypi_0 pypi
sphinxcontrib-devhelp 1.0.5 pypi_0 pypi
sphinxcontrib-htmlhelp 2.0.4 pypi_0 pypi
sphinxcontrib-jsmath 1.0.1 pypi_0 pypi
sphinxcontrib-qthelp 1.0.6 pypi_0 pypi
sphinxcontrib-serializinghtml 1.1.9 pypi_0 pypi
spyder 5.4.5 pypi_0 pypi
spyder-kernels 2.4.4 pypi_0 pypi
stack-data 0.6.3 pypi_0 pypi
tabulate 0.9.0 pypi_0 pypi
tbb 2021.10.0 h91493d7_2 conda-forge
text-unidecode 1.3 pypi_0 pypi
textdistance 4.6.0 pypi_0 pypi
three-merge 0.1.1 pypi_0 pypi
tinycss2 1.2.1 pypi_0 pypi
tk 8.6.13 hcfcfb64_0 conda-forge
tomli 2.0.1 pypi_0 pypi
tomlkit 0.12.1 pypi_0 pypi
toolz 0.12.0 pyhd8ed1ab_0 conda-forge
tornado 6.3.3 pypi_0 pypi
traitlets 5.11.2 pypi_0 pypi
types-python-dateutil 2.8.19.14 pypi_0 pypi
typing-extensions 4.8.0 hd8ed1ab_0 conda-forge
typing_extensions 4.8.0 pyha770c72_0 conda-forge
tzdata 2023c h71feb2d_0 conda-forge
ucrt 10.0.22621.0 h57928b3_0 conda-forge
ujson 5.8.0 pypi_0 pypi
urllib3 2.0.7 pypi_0 pypi
vc 14.3 h64f974e_17 conda-forge
vc14_runtime 14.36.32532 hdcecf7f_17 conda-forge
vs2015_runtime 14.36.32532 h05e6639_17 conda-forge
watchdog 3.0.0 pypi_0 pypi
wcwidth 0.2.8 pypi_0 pypi
webencodings 0.5.1 pypi_0 pypi
whatthepatch 1.0.5 pypi_0 pypi
wheel 0.41.2 pyhd8ed1ab_0 conda-forge
wrapt 1.15.0 pypi_0 pypi
xarray 2023.10.1 pyhd8ed1ab_0 conda-forge
xarray-einstats 0.6.0 pyhd8ed1ab_0 conda-forge
xorg-kbproto 1.0.7 hcd874cb_1002 conda-forge
xorg-libice 1.1.1 hcd874cb_0 conda-forge
xorg-libsm 1.2.4 hcd874cb_0 conda-forge
xorg-libx11 1.8.7 hefa74cf_0 conda-forge
xorg-libxau 1.0.11 hcd874cb_0 conda-forge
xorg-libxdmcp 1.1.3 hcd874cb_0 conda-forge
xorg-libxext 1.3.4 hcd874cb_2 conda-forge
xorg-libxpm 3.5.17 hcd874cb_0 conda-forge
xorg-libxt 1.3.0 hcd874cb_1 conda-forge
xorg-xextproto 7.3.0 hcd874cb_1003 conda-forge
xorg-xproto 7.0.31 hcd874cb_1007 conda-forge
xz 5.2.6 h8d14728_0 conda-forge
yapf 0.40.2 pypi_0 pypi
zipp 3.17.0 pypi_0 pypi
zlib 1.2.13 hcfcfb64_5 conda-forge
zstd 1.5.5 h12be248_0 conda-forge


@maresb Any clue what this means? The BLAS stuff and gcc stuff seems to be in place.

Very weird that pytensor and pytensor-base versions don’t match. That shouldn’t be possible.

The problem is that I am trying to reproduce the example given by PyMC (Model averaging — PyMC3 3.11.4 documentation) and I receive that warning

All I can suggest is creating a new environment and installing PyMC using the instructions found here. The environment you current have seems odd and, as @maresb mentioned, should be what the installation instruction procedure generates.

It is resolved. Thank you

model_dict = dict(zip([“model_0”, “model_1”, “model_2”], traces))
comp = az.compare(model_dict)
comp
After these three lines I received another error knowing that I reproduced the model proposed by PyMC documentation:

TypeError Traceback (most recent call last)
File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:448, in _calculate_ics(compare_dict, scale, ic, var_name)
447 try:
→ 448 compare_dict[name] = ic_func(
449 convert_to_inference_data(dataset),
450 pointwise=True,
451 scale=scale,
452 var_name=var_name,
453 )
454 except Exception as e:

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:766, in loo(data, pointwise, var_name, reff, scale)
765 inference_data = convert_to_inference_data(data)
→ 766 log_likelihood = _get_log_likelihood(inference_data, var_name=var_name)
767 pointwise = rcParams[“stats.ic_pointwise”] if pointwise is None else pointwise

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats_utils.py:425, in get_log_likelihood(idata, var_name)
424 if not hasattr(idata, “log_likelihood”):
→ 425 raise TypeError(“log likelihood not found in inference data object”)
426 if var_name is None:

TypeError: log likelihood not found in inference data object

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last)
File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:177, in compare(compare_dict, ic, method, b_samples, alpha, seed, scale, var_name)
176 try:
→ 177 (ics_dict, scale, ic) = _calculate_ics(compare_dict, scale=scale, ic=ic, var_name=var_name)
178 except Exception as e:

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:455, in _calculate_ics(compare_dict, scale, ic, var_name)
454 except Exception as e:
→ 455 raise e.class(
456 f"Encountered error trying to compute {ic} from model {name}."
457 ) from e
458 return (compare_dict, scale, ic)

TypeError: Encountered error trying to compute loo from model model_0.

The above exception was the direct cause of the following exception:

TypeError Traceback (most recent call last)
Cell In[8], line 2
1 model_dict = dict(zip([“model_0”, “model_1”, “model_2”], traces))
----> 2 comp = az.compare(model_dict)
3 comp

File ~\anaconda3\envs\pymc_env\Lib\site-packages\arviz\stats\stats.py:179, in compare(compare_dict, ic, method, b_samples, alpha, seed, scale, var_name)
177 (ics_dict, scale, ic) = _calculate_ics(compare_dict, scale=scale, ic=ic, var_name=var_name)
178 except Exception as e:
→ 179 raise e.class(“Encountered error in ELPD computation of compare.”) from e
180 names = list(ics_dict.keys())
181 if ic == “loo”:

TypeError: Encountered error in ELPD computation of compare.

Maybe this is the wrong place to ask, but is installation via pip actively supported? I was a bit hesitant since it doesn’t seem to be mentioned in the current version of the docs.

What I saw in the installation is the latest version of PyMC. However in the script proposed, the version of PyMC was pymc3

The short answer is no. The recommended method is detailed here. The reason these are recommended is because conda-forge contains all the stuff to get various C libraries (needed for PyTensor) compiled on your system (and pypi does not).