pymc-devs / pymc-devs/pytensor

BUG: ImportError: cannot import name 'batched_dot' from 'pytensor.tensor.blas'

Open
#2,407 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Describe the issue:

I installed fresh pymc via conda on mac

conda create -c conda-forge -n pymc_env "pymc>=6"
conda activate pymc_env

and when I import pytensor, I got

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 import pytensor

File ~/.conda/envs/pymc/lib/python3.14/site-packages/pytensor/__init__.py:19
     15 from pytensor.configdefaults import config
     18 # isort: off
---> 19 from pytensor import tensor
     20 from pytensor.compile import (
     21     In,
     22     Mode,
   (...)     25     wrap_py,
     26 )
     27 from pytensor.compile.maker import function

File ~/.conda/envs/pymc/lib/python3.14/site-packages/pytensor/tensor/__init__.py:125
    122 from numpy import e, euler_gamma, inf, nan, newaxis, pi
    124 from pytensor.tensor.basic import *
--> 125 from pytensor.tensor.blas import batched_dot, batched_tensordot
    126 from pytensor.tensor.extra_ops import *
    127 from pytensor.tensor.interpolate import interp, interpolate1d

ImportError: cannot import name 'batched_dot' from 'pytensor.tensor.blas' (/Users/xxx/.conda/envs/pymc/lib/python3.14/site-packages/pytensor/tensor/blas/__init__.py)
Reproducable code example:
import pytensor
Error message:

PyTensor version information:

Info from python -c "import pytensor; print(pytensor.config)"

Traceback (most recent call last): File "", line 1, in import pytensor; print(pytensor.config) ^^^^^^^^^^^^^^^ File "/Users/xxx/.conda/envs/pymc/lib/python3.14/site-packages/pytensor/__init__.py", line 19, in from pytensor import tensor File "/Users/xxx/.conda/envs/pymc/lib/python3.14/site-packages/pytensor/tensor/__init__.py", line 125, in from pytensor.tensor.blas import batched_dot, batched_tensordot ImportError: cannot import name 'batched_dot' from 'pytensor.tensor.blas' (/Users/xxx/.conda/envs/pymc/lib/python3.14/site-packages/pytensor/tensor/blas/__init__.py)
Context for the issue:

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the import chain shown in pytensor/init.py and pytensor/tensor/init.py, then inspect pytensor/tensor/blas/init.py to determine why batched_dot is unavailable. Reproduce the failure with the reported conda environment and import pytensor; done means the import succeeds without breaking the batched tensor exports.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.