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

The error description in the document for installation: pip install pymatgen[extra] #1965

Closed
hongyi-zhao opened this issue Sep 27, 2020 · 11 comments

Comments

@hongyi-zhao
Copy link
Contributor

Hi,

The document told the following:

$ egrep -inR 'pymatgen\[extra\]' .
./docs_rst/introduction.rst:182:   pip install pymatgen[extra]

But the output of the following installation command is not coherent with the above description:

$ pip install .[extra]
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Processing /home/werner/Public/hpc/tools/materialsproject/pymatgen.git
  WARNING: pymatgen 2020.9.14 does not provide the extra 'extra'
[...]

Any hints for this problem?

Regards,
HY

@mkhorton
Copy link
Member

Here, "extra" is a placeholder for the specific "extra" that you require.

Currently, you can choose from "provenance", "ase", "vis" or "abinit" (see here).

As with the BoltzTrap2 dependencies, extras are optional. Most users do not need them.

@hongyi-zhao
Copy link
Contributor Author

hongyi-zhao commented Sep 27, 2020

Here, "extra" is a placeholder for the specific "extra" that you require.

Currently, you can choose from "provenance", "ase", "vis" or "abinit" (see here).

Do you mean any of them will do the trick, i.e., running one of the following:

$ pip install .[provenance]
$ pip install .[ase]
$ pip install .[vis]
$ pip install .[abinit]

As with the BoltzTrap2 dependencies, extras are optional. Most users do not need them.

I use the following command to install all possible dependencies:

$ pip install -r requirements.txt -r requirements-dev.txt -r requirements-optional.txt

@mkhorton
Copy link
Member

The recommended way to install pymatgen is either:

pip install pymatgen (or, if you have a desired extra, pip install pymatgen[provenance] etc.)

or

conda install -c conda-forge pymatgen

If you are doing development, then you can manually install those dependencies yourself, such as doing pip install -r requirements.txt, but in general you only need to install dependencies for functionality you want to use. If you're not familiar with this additional functionality or you're not doing development using it, it's safe not to install it.

@hongyi-zhao
Copy link
Contributor Author

hongyi-zhao commented Sep 27, 2020

pip install pymatgen (or, if you have a desired extra, pip install pymatgen[provenance] etc.)

For my case, I run the command immediately under the local git repo root of pymatgen, so I think it should be invoked like the forms I posted previously.

If you are doing development, then you can manually install those dependencies yourself, such as doing pip install -r requirements.txt,

But the requirements.txt doesn't include any of these packages.

@mkhorton
Copy link
Member

Yes, that's correct, because these are optional requirements (hence "extras"), they are in requirements-optional.txt

Perhaps it would be useful to ask what you're intending to use pymatgen for, or why you're installing it? Typically, if you're new to pymatgen, I would recommend following the pip install or conda install instructions above, and not performing git clone etc.

The important thing is to understand that the setup.py and requirements*.txt files both describe similar things but with different purposes. The setup.py is generally used for installing, while the requirements*.txt give you specific known versions of dependencies, and can be useful for development. This structure is fairly typical for a Python code, and not specific to pymatgen itself.

@hongyi-zhao
Copy link
Contributor Author

hongyi-zhao commented Sep 27, 2020

Yes, that's correct, because these are optional requirements (hence "extras"), they are in requirements-optional.txt

But even the requirements-optional.txt doesn't include all the dependencies we discussed here.

@mkhorton
Copy link
Member

I'm sorry, I'm not sure I understand the problem you're having. Pymatgen will work fine even if optional dependencies are not installed. If you find that you want to use a feature for which you don't have the requisite dependency, you will get a message and you can install it.

The requirements-optional.txt does have these optional dependencies, e.g. it has pybtex (the "provenance" extra), it has ase (the "ase" extra), it has netcdf4 (the "abinit" extra), it does not have vtk but this is because vtk can be difficult to install on certain systems and is only used for the visualization package which is being deprecated.

@hongyi-zhao
Copy link
Contributor Author

hongyi-zhao commented Sep 27, 2020

The requirements-optional.txt does have these optional dependencies, e.g. it has pybtex (the "provenance" extra), it has ase (the "ase" extra), it has netcdf4 (the "abinit" extra), it does not have vtk but this is because vtk can be difficult to install on certain systems and is only used for the visualization package which is being deprecated.

Thanks a lot, got it. Another question: do you mean vtk is being deprecated by pymatgen?

@hongyi-zhao
Copy link
Contributor Author

hongyi-zhao commented Sep 28, 2020

The recommended way to install pymatgen is either:

pip install pymatgen (or, if you have a desired extra, pip install pymatgen[provenance] etc.)

There is still another question I can't figure out, see following for more info.

The following codes are the content of extras_require section of setup.py.

    extras_require={
        "provenance": ["pybtex"],
        "ase": ["ase>=3.3"],
        "vis": ["vtk>=6.0.0"],
        "abinit": ["netcdf4"],
        ':python_version < "3.7"': [
            "dataclasses>=0.6",
        ]},

So, if I want to install all of these extra dependencies with one run of pip, I find that only the following command can do the trick:

$ pip install .[provenance,ase,vis,abinit] |grep -i warning
$

And all the following commands failed:

$ pip install .[extras_require] |grep -i warning
  WARNING: pymatgen 2020.9.14 does not provide the extra 'extras_require'
$ pip install .[extras] |grep -i warning
  WARNING: pymatgen 2020.9.14 does not provide the extra 'extras'
$ pip install .[extra] |grep -i warning
  WARNING: pymatgen 2020.9.14 does not provide the extra 'extra'

@mkhorton
Copy link
Member

The correct pip install command would be pip install pymatgen[provenance] etc.

@hongyi-zhao
Copy link
Contributor Author

hongyi-zhao commented Sep 30, 2020

The correct pip install command would be pip install pymatgen[provenance] etc.

I'm still confused why can't I combine them into one like the following, considering that the usage abides with the pip's specification:

$ pip install pymatgen[provenance,ase,vis,abinit]

or run as following if we are directly in the pymatgen's top level subdirectory:

$ pip install .[provenance,ase,vis,abinit]

See here for the discussion relevant to this problem.

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