Cannot import name '_vectorize_node' from 'pytensor.graph.replace'

Hi. After I reinstalled graphviz, pymc and bart did not work properly. So I reinstalled pymc and bart, but still got: cannot import name ‘_vectorize_node’ from ‘pytensor.graph.replace’
Thank you very much.

import lib:

from pathlib import Path
import arviz as az
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
import numpy as np
import pandas as pd
import pymc as pm
import pytensor.tensor as pt
import pymc_bart as pmb
from sklearn.model_selection import train_test_split
%config InlineBackend.figure_format = "retina"
#from pymc.gp.util import plot_gp_dist
#print(f"Running on PyMC v{pm.__version__}")

The error message is as follows:

ImportError                               Traceback (most recent call last)
Cell In[24], line 13
     11 #import pymc as pm
     12 import pytensor.tensor as pt
---> 13 import pymc_bart as pmb
     14 from sklearn.model_selection import train_test_split
     16 get_ipython().run_line_magic('config', 'InlineBackend.figure_format = "retina"')

File ~\.conda\envs\pymc_env\Lib\site-packages\pymc_bart\__init__.py:14
      1 #   Copyright 2022 The PyMC Developers
      2 #
      3 #   Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 #   See the License for the specific language governing permissions and
     13 #   limitations under the License.
---> 14 import pymc as pm
     16 from pymc_bart.bart import BART
     17 from pymc_bart.pgbart import PGBART

File ~\.conda\envs\pymc_env\Lib\site-packages\pymc\__init__.py:48
     43     pytensor.config.gcc__cxxflags = augmented
     46 __set_compiler_flags()
---> 48 from pymc import _version, gp, ode, sampling
     49 from pymc.backends import *
     50 from pymc.blocking import *

File ~\.conda\envs\pymc_env\Lib\site-packages\pymc\gp\__init__.py:15
      1 #   Copyright 2024 The PyMC Developers
      2 #
      3 #   Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 #   See the License for the specific language governing permissions and
     13 #   limitations under the License.
---> 15 from pymc.gp import cov, mean, util
     16 from pymc.gp.gp import (
     17     TP,
     18     Latent,
   (...)
     23     MarginalSparse,
     24 )
     25 from pymc.gp.hsgp_approx import HSGP, HSGPPeriodic

File ~\.conda\envs\pymc_env\Lib\site-packages\pymc\gp\util.py:26
     23 from scipy.cluster.vq import kmeans
     25 # Avoid circular dependency when importing modelcontext
---> 26 from pymc.distributions.distribution import Distribution
     27 from pymc.model import modelcontext
     28 from pymc.pytensorf import compile_pymc

File ~\.conda\envs\pymc_env\Lib\site-packages\pymc\distributions\__init__.py:15
      1 #   Copyright 2024 The PyMC Developers
      2 #
      3 #   Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 #   See the License for the specific language governing permissions and
     13 #   limitations under the License.
---> 15 from pymc.distributions.censored import Censored
     16 from pymc.distributions.continuous import (
     17     AsymmetricLaplace,
     18     Beta,
   (...)
     51     Weibull,
     52 )
     53 from pymc.distributions.discrete import (
     54     Bernoulli,
     55     BetaBinomial,
   (...)
     65     Poisson,
     66 )

File ~\.conda\envs\pymc_env\Lib\site-packages\pymc\distributions\censored.py:21
     18 from pytensor.tensor.random.op import RandomVariable
     19 from pytensor.tensor.random.utils import normalize_size_param
---> 21 from pymc.distributions.distribution import (
     22     Distribution,
     23     SymbolicRandomVariable,
     24     _support_point,
     25 )
     26 from pymc.distributions.shape_utils import (
     27     _change_dist_size,
     28     change_dist_size,
     29     implicit_size_from_params,
     30     rv_size_is_none,
     31 )
     32 from pymc.util import check_dist_not_registered

File ~\.conda\envs\pymc_env\Lib\site-packages\pymc\distributions\distribution.py:37
     35 from pytensor.scan.op import Scan
     36 from pytensor.tensor.basic import as_tensor_variable
---> 37 from pytensor.tensor.blockwise import safe_signature
     38 from pytensor.tensor.random.op import RandomVariable
     39 from pytensor.tensor.random.rewriting import local_subtensor_rv_lift

File ~\.conda\envs\pymc_env\Lib\site-packages\pytensor\tensor\blockwise.py:12
     10 from pytensor.graph.null_type import NullType
     11 from pytensor.graph.op import Op
---> 12 from pytensor.graph.replace import (
     13     _vectorize_node,
     14     _vectorize_not_needed,
     15     vectorize_graph,
     16 )
     17 from pytensor.scalar import ScalarType
     18 from pytensor.tensor import as_tensor_variable

ImportError: cannot import name '_vectorize_node' from 'pytensor.graph.replace' (C:\Users\Jj\.conda\envs\pymc_env\Lib\site-packages\pytensor\graph\replace.py)

my conda list as follows:

# Name                    Version                   Build  Channel
arviz                     0.18.0             pyhd8ed1ab_0    conda-forge
asttokens                 2.0.5              pyhd3eb1b0_0
blas                      1.0                         mkl
bottleneck                1.3.7           py311hd7041d2_0
brotli                    1.0.9                h2bbff1b_8
brotli-bin                1.0.9                h2bbff1b_8
bzip2                     1.0.8                h2bbff1b_6
ca-certificates           2024.3.11            haa95532_0
cachetools                5.3.3              pyhd8ed1ab_0    conda-forge
cairo                     1.16.0               haedb8bc_5
certifi                   2024.2.2           pyhd8ed1ab_0    conda-forge
cloudpickle               3.0.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6           py311haa95532_0
comm                      0.2.1           py311haa95532_0
cons                      0.4.6              pyhd8ed1ab_0    conda-forge
contourpy                 1.2.0           py311h59b6b97_0
cycler                    0.11.0             pyhd3eb1b0_0
decorator                 5.1.1              pyhd3eb1b0_0
dm-tree                   0.1.8           py311hb041b4a_4    conda-forge
etuples                   0.3.9              pyhd8ed1ab_0    conda-forge
executing                 0.8.3              pyhd3eb1b0_0
expat                     2.6.2                h63175ca_0    conda-forge
filelock                  3.14.0             pyhd8ed1ab_0    conda-forge
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                 h77eed37_2    conda-forge
fontconfig                2.14.1               h9c4af85_2
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.51.0          py311h2bbff1b_0
freetype                  2.12.1               ha860e81_0
fribidi                   1.0.10               h8d14728_0    conda-forge
fsspec                    2023.10.0       py311haa95532_0
getopt-win32              0.1                  hcfcfb64_1    conda-forge
glib                      2.78.4               hd77b12b_0
glib-tools                2.78.4               hd77b12b_0
graphite2                 1.3.13            h63175ca_1003    conda-forge
graphviz                  7.1.0                h51cb2cd_0    conda-forge
gts                       0.7.6                h6b5321d_4    conda-forge
h5netcdf                  1.3.0              pyhd8ed1ab_0    conda-forge
h5py                      3.11.0          py311h765d3d0_0
harfbuzz                  6.0.0                h196d34a_1    conda-forge
hdf5                      1.12.1               h51c971a_3
icc_rt                    2022.1.0             h6049295_2
icu                       72.1                 h63175ca_0    conda-forge
intel-openmp              2023.1.0         h59b6b97_46320
ipython                   8.20.0          py311haa95532_0
ipywidgets                8.1.2           py311haa95532_0
jedi                      0.18.1          py311haa95532_1
joblib                    1.4.0           py311haa95532_0
jpeg                      9e                   h2bbff1b_1
jupyterlab_widgets        3.0.10          py311haa95532_0
kiwisolver                1.4.4           py311hd77b12b_0
lcms2                     2.12                 h83e58a3_0
lerc                      3.0                  hd77b12b_0
libabseil                 20240116.2      cxx17_h63175ca_0    conda-forge
libbrotlicommon           1.0.9                h2bbff1b_8
libbrotlidec              1.0.9                h2bbff1b_8
libbrotlienc              1.0.9                h2bbff1b_8
libdeflate                1.17                 h2bbff1b_1
libexpat                  2.6.2                h63175ca_0    conda-forge
libffi                    3.4.4                hd77b12b_1
libgd                     2.3.3                ha43c60c_1
libglib                   2.78.4               ha17d25a_0
libiconv                  1.17                 hcfcfb64_2    conda-forge
libpng                    1.6.39               h8cc25b3_0
libpython                 2.2             py311h1ea47a8_3    conda-forge
libtiff                   4.5.1                hd77b12b_0
libwebp-base              1.3.2                h2bbff1b_0
libxml2                   2.10.4               h0ad7f3c_2
llvmlite                  0.42.0          py311hf2fb9eb_0
logical-unification       0.4.6              pyhd8ed1ab_0    conda-forge
lz4-c                     1.9.4                h2bbff1b_1
m2w64-binutils            2.25.1                        5    conda-forge
m2w64-bzip2               1.0.6                         6    conda-forge
m2w64-crt-git             5.0.0.4636.2595836               2    conda-forge
m2w64-gcc                 5.3.0                         6    conda-forge
m2w64-gcc-ada             5.3.0                         6    conda-forge
m2w64-gcc-fortran         5.3.0                         6    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-gcc-objc            5.3.0                         6    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-headers-git         5.0.0.4636.c0ad18a               2    conda-forge
m2w64-isl                 0.16.1                        2    conda-forge
m2w64-libiconv            1.14                          6    conda-forge
m2w64-libmangle-git       5.0.0.4509.2e5a9a2               2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
m2w64-make                4.1.2351.a80a8b8               2    conda-forge
m2w64-mpc                 1.0.3                         3    conda-forge
m2w64-mpfr                3.1.4                         4    conda-forge
m2w64-pkg-config          0.29.1                        2    conda-forge
m2w64-toolchain           5.3.0                         7    conda-forge
m2w64-toolchain_win-64    2.5.0                h57928b3_0    conda-forge
m2w64-tools-git           5.0.0.4592.90b8472               2    conda-forge
m2w64-windows-default-manifest 6.4                           3    conda-forge
m2w64-winpthreads-git     5.0.0.4634.697f757               2    conda-forge
m2w64-zlib                1.2.8                        10    conda-forge
markdown-it-py            3.0.0              pyhd8ed1ab_0    conda-forge
matplotlib-base           3.8.4           py311hf62ec03_0
matplotlib-inline         0.1.6           py311haa95532_0
mdurl                     0.1.2              pyhd8ed1ab_0    conda-forge
minikanren                1.0.3              pyhd8ed1ab_0    conda-forge
mkl                       2023.1.0         h6b88ed4_46358
mkl-service               2.4.0           py311h2bbff1b_1
mkl_fft                   1.3.8           py311h2bbff1b_0
mkl_random                1.2.4           py311h59b6b97_0
msys2-conda-epoch         20160418                      1    conda-forge
multipledispatch          0.6.0                      py_0    conda-forge
numba                     0.59.1          py311h2c0921f_0    conda-forge
numexpr                   2.8.7           py311h1fcbade_0
numpy                     1.24.3          py311hdab7c0b_1
numpy-base                1.24.3          py311hd01c5d8_1
openjpeg                  2.4.0                h4fc8c34_0
openssl                   3.3.0                h2466b09_3    conda-forge
packaging                 23.2            py311haa95532_0
pandas                    2.2.1           py311hea22821_0
pango                     1.50.12              hdffb7b3_1    conda-forge
parso                     0.8.3              pyhd3eb1b0_0
pcre2                     10.42                h0ff8eda_1
pillow                    10.3.0          py311h2bbff1b_0
pip                       24.0            py311haa95532_0
pixman                    0.43.4               h63175ca_0    conda-forge
prompt-toolkit            3.0.43          py311haa95532_0
prompt_toolkit            3.0.43               hd3eb1b0_0
pure_eval                 0.2.2              pyhd3eb1b0_0
pygments                  2.18.0             pyhd8ed1ab_0    conda-forge
pymc                      5.15.1               hd8ed1ab_0    conda-forge
pymc-bart                 0.5.14             pyhd8ed1ab_0    conda-forge
pymc-base                 5.15.1             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9           py311haa95532_0
pytensor                  2.22.1          py311h6fc7ef1_0    conda-forge
pytensor-base             2.22.1          py311hbc92ba2_0    conda-forge
python                    3.11.9               he1021f5_0
python-dateutil           2.9.0post0      py311haa95532_2
python-graphviz           0.20.3             pyh717bed2_0    conda-forge
python-tzdata             2023.3             pyhd3eb1b0_0
python_abi                3.11                    2_cp311    conda-forge
pytz                      2024.1          py311haa95532_0
rich                      13.7.1             pyhd8ed1ab_0    conda-forge
scikit-learn              1.4.2           py311hf62ec03_1
scipy                     1.12.0          py311h9f229c6_0
seaborn                   0.12.2          py311haa95532_0
setuptools                69.5.1          py311haa95532_0
six                       1.16.0             pyhd3eb1b0_1
sqlite                    3.45.3               h2bbff1b_0
stack_data                0.2.0              pyhd3eb1b0_0
tbb                       2021.8.0             h59b6b97_0
threadpoolctl             2.2.0              pyh0d69192_0
tk                        8.6.14               h0416ee5_0
toolz                     0.12.1             pyhd8ed1ab_0    conda-forge
traitlets                 5.9.0                    pypi_0    pypi
typing-extensions         4.11.0          py311haa95532_0
typing_extensions         4.11.0          py311haa95532_0
tzdata                    2024a                h04d1e81_0
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
unicodedata2              15.1.0          py311h2bbff1b_0
vc                        14.2                 h2eaa2aa_1
vc14_runtime              14.38.33135         h835141b_20    conda-forge
vs2015_runtime            14.38.33135         h22015db_20    conda-forge
wcwidth                   0.2.5              pyhd3eb1b0_0
wheel                     0.43.0          py311haa95532_0
widgetsnbextension        4.0.10          py311haa95532_0
xarray                    2023.6.0        py311haa95532_0
xarray-einstats           0.7.0              pyhd8ed1ab_0    conda-forge
xz                        5.4.6                h8cc25b3_1
zlib                      1.2.13               h8cc25b3_1
zstd                      1.5.5                hd43e919_2

That’s strange. Can you try to install pymc==5.15.0 instead?

I re-install pymc=5.15.0 and pymc-bart=0.5.12, or pymc=5.15.0 and pymc-bart=0.5.14. It works. But there a new problem has arisen. The calculation is very slow. It used to take 40 seconds, but now it takes 50 minutes. Very strange.
And, it’s very strange that I re-install pymc=5.15.0 and pymc-bart=0.5.14 last night, it not works.
Thank you very much.

re-install pymc=5.15.1, pytensor=2.5.13,pytensor-base=2.22.1,pymc-bart=0.5.14. It works, but very slow. When update pytensor=2.22.1, get error: module ‘pytensor’ has no attribute ‘config’
I think the problem is pytensor version.

First, I uninstalled pytensor. The pymc version became 4.4. But pytensor-base haven’t deleted, still 2.22.1. Then I uninstall pytensor-base. Subsequently, I installed pymc=5.15.0. It works quickly.
Remeber don’t delete pymc-bart.
So the problem is pytensor and pytensor-base versions.
Finally, pymc=5.15.0, pytensor=2.13.1, pytensor-base=2.20.0, pymc-bart=0.5.14
Thank you very much.