ImportError: cannot import name 'which'
Closed this issue · 3 comments
I was able to successfully install everything using python 3.6.9. However when I run dock.py, I get this error:
-packages/pymatgen/analysis/graphs.py", line 22, in <module>
from monty.os.path import which
ImportError: cannot import name 'which'
I already tried doing a conda install which. It worked. But the strange thing is I can not import this module. See:
(VOID369) [hussaif1@login-03 site-packages]$ python
Python 3.6.9 | packaged by conda-forge | (default, Mar 6 2020, 19:24:21)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import which
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'which'
>>>
I finally was able to try with 3.6.8 but still get the same error below. Will try next on a new system unrelated to this one to if the error is reproduceable..
(VOID) [hussaif1@vis-ws-vm-045 bin]$ python dock.py
Traceback (most recent call last):
File "dock.py", line 5, in <module>
from VOID.utils.parser import DockParser
File "/gpfs/users/home/hussaif1/.local/lib/python3.6/site-packages/VOID/utils/parser/__init__.py", line 2, in <module>
from .dock import DockParser
File "/gpfs/users/home/hussaif1/.local/lib/python3.6/site-packages/VOID/utils/parser/dock.py", line 2, in <module>
from VOID import dockers, samplers, fitness
File "/gpfs/users/home/hussaif1/.local/lib/python3.6/site-packages/VOID/dockers/__init__.py", line 1, in <module>
from .base import Docker
File "/gpfs/users/home/hussaif1/.local/lib/python3.6/site-packages/VOID/dockers/base.py", line 5, in <module>
from VOID.structure import Complex
File "/gpfs/users/home/hussaif1/.local/lib/python3.6/site-packages/VOID/structure/__init__.py", line 1, in <module>
from .complex import Complex
File "/gpfs/users/home/hussaif1/.local/lib/python3.6/site-packages/VOID/structure/complex.py", line 4, in <module>
from .molecule import MoleculeTransformer
File "/gpfs/users/home/hussaif1/.local/lib/python3.6/site-packages/VOID/structure/molecule.py", line 6, in <module>
from pymatgen.analysis.graphs import MoleculeGraph
File "/gpfs/users/home/hussaif1/miniconda3/envs/VOID/lib/python3.6/site-packages/pymatgen/analysis/graphs.py", line 22, in <module>
from monty.os.path import which
ImportError: cannot import name 'which'
Tried on another system and got the same error. Some googling suggests it is a Python 2 related error. My systems do not have Python 2. I opened an issue with the pymatgen folks here:
I was able to resolve the issue by downgrading my monty package as follows:
pip install 'monty==2022.4.26' --force-reinstall
Now it seems to work as expected!