Repository: materialsproject/pymatgen

Issue #3170: ImportError when using abicheck.py with abipy and pymatgen
Created: 2023-07-20T14:33:11Z
I'm encountering an issue when trying to use abicheck.py with the abipy and pymatgen libraries in my abienv conda environment. Here's the command I'm running and the error I'm facing:
Command:
(abienv) mtk@mtk-HP-EliteBook-x360-1030-G2:~/abipy$ abicheck.py --with-flow
Error :
/home/mtk/miniconda3/envs/abienv/bin/abicheck.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import('pkg_resources').run_script('abipy==0.9.3', 'abicheck.py')
Traceback (most recent call last):
File "/home/mtk/miniconda3/envs/abienv/bin/abicheck.py", line 4, in
import('pkg_resources').run_script('abipy==0.9.3', 'abicheck.py')
File "/home/mtk/miniconda3/envs/abienv/lib/python3.9/site-packages/pkg_resources/init.py", line 722, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/home/mtk/miniconda3/envs/abienv/lib/python3.9/site-packages/pkg_resources/init.py", line 1561, in run_script
exec(code, namespace, namespace)
File "/home/mtk/miniconda3/envs/abienv/lib/python3.9/site-packages/abipy-0.9.3-py3.9.egg/EGG-INFO/scripts/abicheck.py", line 11, in
import abipy.flowtk as flowtk
File "/home/mtk/miniconda3/envs/abienv/lib/python3.9/site-packages/abipy-0.9.3-py3.9.egg/abipy/flowtk/init.py", line 15, in
from .tasks import *
File "/home/mtk/miniconda3/envs/abienv/lib/python3.9/site-packages/abipy-0.9.3-py3.9.egg/abipy/flowtk/tasks.py", line 36, in
from .abitimer import AbinitTimerParser
File "/home/mtk/miniconda3/envs/abienv/lib/python3.9/site-packages/abipy-0.9.3-py3.9.egg/abipy/flowtk/abitimer.py", line 2, in
from pymatgen.io.abinit.abitimer import AbinitTimerParserError, AbinitTimerParser, AbinitTimerSection
ImportError: cannot import name 'AbinitTimerParserError' from 'pymatgen.io.abinit.abitimer' (/home/mtk/miniconda3/envs/abienv/lib/python3.9/site-packages/pymatgen/io/abinit/abitimer.py)
It seems that the AbinitTimerParserError class is not being imported from the pymatgen.io.abinit.abitimer module, causing the ImportError. I have already checked that both abipy and pymatgen are installed in my abienv environment.
I have tried updating both abipy and pymatgen using conda update, but the issue persists. I'm using Python 3.9.
Any suggestions on how to resolve this issue would be greatly appreciated. Thank you in advance for your help!

Duplicate issue #3208: Typo in pymatgen.io.abinit.abitimer module AbinitTimerParserError
Created: 2023-08-03T09:34:41Z
Description
While I have been using pymatgen for a while, I recently wanted to try using abipy to do some calculations in abinit. Using one of the example jupyter notebooks, there is an import line
pymatgen.io.abinit.abitimer import AbinitTimerParserError 
The import fails. Investigation of the modules available shows that there is a module "AbinitTimerParseError".  My guess is that this was meant to be "AbinitTimerParserError" as the Jupyter notebook line indicates.
Repro
Steps to reproduce the behavior:

install abipy using pip
start ipython
"import abipy"

This fails within the abipy.abitimer module with the error message
ImportError                               Traceback (most recent call last)
Cell In[5], line 1
----> 1 from pymatgen.io.abinit.abitimer import AbinitTimerParserError

ImportError: cannot import name 'AbinitTimerParserError' from 'pymatgen.io.abinit.abitimer' (/data/miniconda/envs/abipy/lib/python3.11/site-packages/pymatgen/io/abinit/abitimer.py)


The line, "from pymatgen.io.abinit.abitimer import AbinitTimerParseError" works fine however. The pymatgen documentation only shows the module AbinitTimerParserError suggesting that a typo exists in pymatgen.io.abinit.abitimer
I manually fixed the error by changing two lines in pymatgen.io.abinit.abitimer
Line 35
class AbinitTimerParseError(ParseError): -> class AbinitTimerParserError(ParseError):
Line 58
Error = AbinitTimerParseError -> Error = AbinitTimerParserError
Expected behavior
Successful import of abipy
Environment
Relevant versions and platform info:
Centos 7
pymatgen-2023.7.20
abipy-0.9.3
Additional context
More context like related issues/PRs.

Closing comment (2023-08-03T16:59:28Z): Duplicate of #3170. See #3170 (comment) for the fix.