a-r-j / graphein

Protein Graph Library
https://graphein.ai/
MIT License
994 stars 125 forks source link

`pip install` fails on fresh `python==3.11` and `python==3.10` conda environment #381

Open kamurani opened 3 months ago

kamurani commented 3 months ago

On a clean conda environment created with conda create -n env_name python==3.11 on Linux, and then

pip install graphein 
graphein

I get the following:

[04/05/24 12:07:30] WARNING  To use the Graphein submodule graphein.protein.features.sequence.embeddings, you need to   embeddings.py:34
                             install: torch                                                                                             
                             To do so, use the following command: pip install torch                                                     
                    WARNING  To use the Graphein submodule graphein.protein.features.sequence.embeddings, you need to   embeddings.py:45
                             install: biovec                                                                                            
                             To do so, use the following command: pip install biovec                                                    
                             Alternatively, you can install graphein with the extras:                                                   

                             pip install graphein[extras]                                                                               
                    WARNING  To use the Graphein submodule graphein.protein.visualisation, you need to install:      visualisation.py:36
                             pytorch3d                                                                                                  
                             pytorch3d cannot be installed via pip                                                                      
                    WARNING  To use the Graphein submodule graphein.protein.meshes, you need to install: pytorch3d          meshes.py:30
                             To do so, use the following command: pip install pytorch3d                                                 
Traceback (most recent call last):
  File "/home/cam/.local/bin/graphein", line 5, in <module>
    from graphein.cli import main
  File "/home/cam/.local/lib/python3.10/site-packages/graphein/cli.py", line 10, in <module>
    from graphein.utils.config_parser import parse_config
  File "/home/cam/.local/lib/python3.10/site-packages/graphein/utils/config_parser.py", line 11, in <module>
    from graphein.molecule.config import MoleculeGraphConfig
  File "/home/cam/.local/lib/python3.10/site-packages/graphein/molecule/__init__.py", line 1, in <module>
    from .atoms import *
  File "/home/cam/.local/lib/python3.10/site-packages/graphein/molecule/atoms.py", line 98, in <module>
    Chem.rdchem.HybridizationType.SP,
NameError: name 'Chem' is not defined

Appears that the try: except: wrapper around the import statement isn't doing what it's meant to? Nothing mentioning rdkit was picked up in the pip install as far as I can tell.

# graphein/molecule/atoms.py
try:
    import rdkit.Chem as Chem
except ImportError:
    import_message(
        "graphein.molecule.atoms", "rdkit", "rdkit", True, extras=True
    )

Note: this occurs when using python==3.10 as well.

a-r-j commented 3 months ago

Thanks for flagging. I think pip install rdkit will do the trick for now. Looks like there are some imports that need to be caught and some better logging too.