abinit / abipy

Open-source library for analyzing the results produced by ABINIT
http://abinit.github.io/abipy
Other
117 stars 96 forks source link

error in import abilib #254

Open rajeshatiitm opened 2 years ago

rajeshatiitm commented 2 years ago

Dear abipy developer,

I am using ubuntu 18.04 and abinit9. After installation using conda and running this command

"from abipy import abilab" I get the falling error:


ImportError Traceback (most recent call last) Cell In [4], line 1 ----> 1 from abipy import abilab

File ~/Desktop/abipy/abipy/abipy/init.py:18 12 del sys 14 #----------------------------------------------------------------------------- 15 # Setup the top level names 16 #----------------------------------------------------------------------------- ---> 18 from abipy.core import release 20 # Release data 21 author = ''

File ~/Desktop/abipy/abipy/abipy/core/init.py:3 1 """Core objects.""" 2 # flake8: noqa ----> 3 from .kpoints import 4 from .structure import 5 from .symmetries import *

File ~/Desktop/abipy/abipy/abipy/core/kpoints.py:16 14 from monty.string import marquee 15 from pymatgen.core.lattice import Lattice ---> 16 from pymatgen.util.serialization import pmg_serialize, SlotPickleMixin 17 from abipy.iotools import ETSF_Reader 18 from abipy.tools.derivatives import finite_diff

ImportError: cannot import name 'SlotPickleMixin' from 'pymatgen.util.serialization' (/home/rd/miniconda3/envs/my_pymatgen/lib/python3.10/site-packages/pymatgen/util/serialization.py)


Could you please help to resolve the issue?

Many thanks and regards, Rajesh

gmatteo commented 2 years ago

In the new version of pymatgen, SlotPickleMixin has been removed thus breaking backward compatibility. A patch addressing the problem has been merged in #253 and will be made available in v0.9.3

For the time being, one has to install an older version of pymargen with e.g.:

pip install pymatgen==2022.9.8

See also this pymatgen issue

rajeshatiitm commented 2 years ago

I have successfully installed the abipy using "pip install abipy --user". Using ipython I can test the installation is ok like "from abipy import abilab"

However, I can not execute abiopen.py in Ubuntu terminal! it says command not found.

Could you please help me to find out what I am doing wrong?

Thanks!

gmatteo commented 2 years ago

Could you please help me to find out what I am doing wrong?

You are using conda to manage your python installation so you need to activate the conda environment where abipy has been installed with e.g.:

conda activate my_pymatgen

in order to have the python scripts in $PATH.

PS: The --user option is not needed when conda envs are used. To install python packages in a conda env, activate the env then use

conda install abipy -c conda-forge

or

pip install abipy
rajeshatiitm commented 2 years ago

I did the following: -->conda install pymatgen==2022.9.8 -->conda create --name my_pymatgen python -->conda activate my_pymatgen -->conda create --name abienv python=3.10 -->conda activate abienv -->conda config --add channels conda-forge -->conda install abipy -c conda-forge

then I tested as before in ipython "from abipy import abilab" and it works. I can even see that abipy is installed where it says

"The following NEW packages will be installed abipy conda-forge/noarch::abipy-0.9.2-pyhd8ed1ab_0 None"

then I executed in terminal $ abipy and it says "abipy: command not found

Any help please!

gmatteo commented 2 years ago

then I executed in terminal $ abipy and it says "abipy: command not found

Abipy is the name of the python package so it's normal that you cannot invoke it directly from the shell. There are several scripts that can be used to post-process the data directly from the shell: abistruct.py, abiopen.py, etc.

For the full list of scripts installed by abipy see this page

rajeshatiitm commented 2 years ago

Hi Gmatteo,

I can work with abilab in jupyter notbook, it works nicely, but I can not execute in terminal. I get the following error $ abiopen.py --help Traceback (most recent call last): File "/home/rdutta/anaconda3/bin/abiopen.py", line 4, in import('pkg_resources').run_script('abipy==0.9.2', 'abiopen.py') File "/home/rdutta/anaconda3/lib/python3.9/site-packages/pkg_resources/init.py", line 662, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/rdutta/anaconda3/lib/python3.9/site-packages/pkg_resources/init.py", line 1447, in run_script raise ResolutionError( pkg_resources.ResolutionError: Script 'scripts/abiopen.py' not found in metadata at '/home/rdutta/.local/lib/python3.9/site-packages/abipy-0.9.2.dist-info'

rajeshatiitm commented 2 years ago

However, I can manually copy that abiopen.py into the working directory (where I am working on example), then it works with command ./abiopen.py.

I don't know why does it not work just as $abiopen.py ?