Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in import abilib #254

Open
rajeshatiitm opened this issue Sep 29, 2022 · 7 comments
Open

error in import abilib #254

rajeshatiitm opened this issue Sep 29, 2022 · 7 comments

Comments

@rajeshatiitm
Copy link

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
Copy link
Member

gmatteo commented Sep 29, 2022

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
Copy link
Author

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
Copy link
Member

gmatteo commented Sep 30, 2022

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
Copy link
Author

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
Copy link
Member

gmatteo commented Sep 30, 2022

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
Copy link
Author

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
Copy link
Author

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants