[Error] importing pymc3 with theano-pymc: 'numpy' has no attribute 'bool'

Hi,

I was trying to install pymc3 v3.11.4 on Anaconda 23.9.0 with Python v3.8.10 on Ubuntu 22.04.3 LTS.
Therefore I am using the module theano-pymc but when trying to import pymc3, I’m getting the error

>>> import pymc3
/home/julian/anaconda3/envs/python3.8.10_/lib/python3.8/site-packages/theano/scalar/basic.py:2412: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  self.ctor = getattr(np, o_type.dtype)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/julian/anaconda3/envs/python3.8.10_/lib/python3.8/site-packages/pymc3/__init__.py", line 23, in <module>
    import theano
  File "/home/julian/anaconda3/envs/python3.8.10_/lib/python3.8/site-packages/theano/__init__.py", line 83, in <module>
    from theano import scalar, tensor
  File "/home/julian/anaconda3/envs/python3.8.10_/lib/python3.8/site-packages/theano/scalar/__init__.py", line 1, in <module>
    from .basic import *
  File "/home/julian/anaconda3/envs/python3.8.10_/lib/python3.8/site-packages/theano/scalar/basic.py", line 2460, in <module>
    convert_to_bool = Cast(bool, name="convert_to_bool")
  File "/home/julian/anaconda3/envs/python3.8.10_/lib/python3.8/site-packages/theano/scalar/basic.py", line 2412, in __init__
    self.ctor = getattr(np, o_type.dtype)
  File "/home/julian/anaconda3/envs/python3.8.10_/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
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

my install procedure is the following:

conda create -n python3.8.10 python=3.8.10 -c conda-forge
conda activate python3.8.10
conda install -c conda-forge ipykernel
python -m ipykernel install --user --name=python3.8.10
conda install theano-pymc
conda install pymc3

Hope you have an idea how to solve the compatibility issue :slight_smile:

pymc3 and theano-pymc are legacy packages that are no longer officially supported or maintained. It’s strongly recommended that you upgrade to the latest version of PyMC (5.9.1), by following the official installation guide.

If, for whatever reason, you are totally unable to switch to the latest version, you are going to need to manually specify that older versions of dependencies be installed. In this case, the error tells you that numpy depreciated np.bool in version 1.20.0, so you will need to downgrade numpy to less than 1.20.0.

1 Like