After installation of pyMC4, pytest is failing with "ModuleNotFoundError: No module named 'aesara'"

Hey there. I have installed pymc4 using the instructions on github for MacOS. Now I have opened the pymc folder in pycharm, and am running pytest to see if things are working (using the env from pymc/conda-envs/environment-dev-py39.yml).
When I run pytest I get

‘ERROR - ModuleNotFoundError: No module named ‘aesara’’.

Any pointers as to where in the install I have missed something/gone wrong?

Hi, have you check to see if aesara is already installed?

After activate the conda environment (by running conda activate pymc-dev-py39, You can run the command pip list | grep aesara to check if aesara is available.
Or just run pip list to see all the installed packages.

if aesara is not available, you may try to re-install by running:
pip install -r requirements.txt
or
pip install -r requirements-dev.txt

2 Likes

Thanks @DanhPhan, fixed it. Tests are running now, let’ see how they fare. :wink:

1 Like

Tests are done… I get 24 failures. Some of them due to more missing modules (numpyro and blackjax), some to NotImplementedError: Logprob method not implemented for Simulator_rv{0, (0, 0), floatX, False}.

Before I ask more questions :wink: - can I see the current test failures somewhere on your github repo, to check if what I see is expected?

And should the two missing modules mentioned above be included in the requirements.txt or environment yml?

The tests should all pass @anne. You can see the status of our continuous integration in the Github repository here GitHub - pymc-devs/pymc: Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Aesara, which shows a badge: pytest: passing.

You probably have not installed all development dependencies correctly to be able to run the tests. Also note that the tests can take a couple of hours to run, so it’s going to be a painful process if you want to run them all

2 Likes

Thanks for pointing out the pytest badge on github, @ricardoV94! Regarding the dependencies, my general philosophy is that conda should do it for me… so the question is - why hasn’t it? Or am I wrong in my assumptions here?

I did notice indeed that the tests are slow to run. I haven’t looked into it at all but maybe you know - is this a question of having slow individual tests (in which case @pytest.mark.slow would help), or some other underlying cause?

To run the tests you have to install the conda dev environment. It should work out of the box

That is what I am saying - I have the conda env (pymc-dev-py39), yet it is not working for me. :frowning_face:

@anne Did you manage to solve your problem? I also installed the conda env pymc-dev-py39, and I am getting some failures like NotImplementedError: Logprob method not implemented for Simulator_rv{0, (0, 0), floatX, False} as well.

I am still trying to figure out what is wrong here, because some examples/functions do work, but the one that I need to use doesn’t :frowning:

@amanda.azevedo I haven’t looked into this much further. For what it’s worth, the code seems to be calling this function here:

@singledispatch
def _logprob(
op: Op,
values: Tuple[TensorVariable],
*inputs: TensorVariable,
**kwargs,
):
“”"Create a graph for the log-density/mass of a RandomVariable.

This function dispatches on the type of ``op``, which should be a subclass
of ``RandomVariable``.  If you want to implement new density/mass graphs
for a ``RandomVariable``, register a new function on this dispatcher.

"""
raise NotImplementedError(f"Logprob method not implemented for {op}")

All this function does in my (and presumably your) case is raise a NotImplementedError. I assume that @ricardo94 has a working implementation for that function, hence does not get that test failure.

The function is from aeppl, in my case running from .../pymc-dev-py39/lib/python3.9/site-packages/aeppl/logprob.py, with version

aeppl 0.0.28 pyhd8ed1ab_0 conda-forge

@ricardo94 is this the version you are expecting to be used?

Thanks, @anne!

Another colleague attempted to install PyMC on his Mac and also had this same error. Then, we decided to test it on Linux installing via pip and everything worked as expected, so I guess it is something specific to the installation on macOS.

1 Like

The beta installation instructions have been updated to now recommend installing from conda-forge:

conda create -c conda-forge -n pymc_env python=3.9 pymc
conda activate pymc_env

The v4b6 was missed during packaging, so this will currently install v4b5. But you could try that and see if you are still having difficulties.