materialsvirtuallab / maml

Python for Materials Machine Learning, Materials Descriptors, Machine Learning Force Fields, Deep Learning, etc.
BSD 3-Clause "New" or "Revised" License
362 stars 79 forks source link

MTP example notebook (issue with imports) #560

Closed michaelmacisaac closed 1 year ago

michaelmacisaac commented 1 year ago

Hi, I am wanting to use maml to develop an MTP potential, when I try to use the example notebook I get the following error:


ImportError Traceback (most recent call last) Cell In[2], line 1 ----> 1 from maml.apps.pes import MTPotential 3 mtp = MTPotential()

File ~/.local/lib/python3.11/site-packages/maml/apps/pes/init.py:7 4 """This package contains PotentialMixin classes representing Interatomic Potentials.""" 6 from ._base import Potential, PotentialMixin # noqa ----> 7 from ._gap import GAPotential # noqa 8 from ._lammps import DefectFormation # noqa 9 from ._lammps import ElasticConstant # noqa

File ~/.local/lib/python3.11/site-packages/maml/apps/pes/_gap.py:14 12 import numpy as np 13 from monty.io import zopen ---> 14 from monty.os.path import which 15 from monty.serialization import loadfn 16 from monty.tempfile import ScratchDir

ImportError: cannot import name 'which' from 'monty.os.path' (/home/michaelmacisaac/.local/lib/python3.11/site-packages/monty/os/path.py)

Assistance resolving this issue would be appreciated

michaelmacisaac commented 1 year ago

Fix for this issue: Replace all "monty.os.path import which" with " from shutil import which"

JiQi535 commented 1 year ago

@michaelmacisaac Thanks for raising this issue. Since Nov 2022, the maml codes on github is already using "from shutil import which". If you download the latest version of maml from github and install with pip, then this issue should no longer exists.

@shyuep Hi Shyue Ping, would you help to update the released version of maml on pypi? The current version is updated in Sep 2022.