pytorch / captum

Model interpretability and understanding for PyTorch
https://captum.ai
BSD 3-Clause "New" or "Revised" License
4.8k stars 485 forks source link

Cannot import captum in different envs #1169

Open fmorenopino opened 1 year ago

fmorenopino commented 1 year ago

🐛 Bug

I have been trying to import and using captum in different environments and different machines and I cannot import them (no problem on the installation).

To Reproduce

For example, trying to import it from the tutorials as follows:

from captum.attr import IntegratedGradients
from captum.attr import LayerConductance
from captum.attr import NeuronConductance

Results in the following error:

ModuleNotFoundError: No module named 'captum.attr'; 'captum' is not a package

Tested on python 3.10.12, linux and mac, and Pytorch 2.0.1+cu117.

solwarsop commented 5 months ago

Were you using conda/mamba? I've only been able to get this working by installing via pip.

825728139 commented 4 months ago

I've met the question as you too. I looked at the directory of the conda virtual environment and found that captum was not installed into the Lib\site-packages\ directory, but instead installed a site-packages directory that it created on its own under the home directory. I solved this problem by copying the file to Lib.

solwarsop commented 4 months ago

Duplicate of #1207