facebookresearch / esm

Evolutionary Scale Modeling (esm): Pretrained language models for proteins
MIT License
3.16k stars 627 forks source link

AttributeError: module 'esm' has no attribute 'Alphabet' #216

Closed BenjyNStrauss closed 2 years ago

BenjyNStrauss commented 2 years ago

NOTE: if this is not a bug report, please use the GitHub Discussions for support questions (How do I do X?), feature requests, ideas, showcasing new applications, etc.

Bug description After I install esm, when I run the code in the readme, I get the error: "AttributeError: module 'esm' has no attribute 'Alphabet'"

Reproduction steps Install either version using pip, then run the code following the line "After pip install, you can load and use a pretrained model as follows:"

Expected behavior I did not expect that error to occur

Logs

Traceback (most recent call last):
  File "/Users/bns/workspace/SwiPredNN/scripts/install-pretrained.py", line 12, in <module>
    model, alphabet = esm.pretrained.esm1b_t33_650M_UR50S()
  File "/Users/bns/workspace/SwiPredNN/esm/pretrained.py", line 231, in esm1b_t33_650M_UR50S
    return load_model_and_alphabet_hub("esm1b_t33_650M_UR50S")
  File "/Users/bns/workspace/SwiPredNN/esm/pretrained.py", line 57, in load_model_and_alphabet_hub
    return load_model_and_alphabet_core(model_data, regression_data)
  File "/Users/bns/workspace/SwiPredNN/esm/pretrained.py", line 83, in load_model_and_alphabet_core
    alphabet = esm.Alphabet.from_architecture(model_data["args"].arch)
AttributeError: module 'esm' has no attribute 'Alphabet'

Additional context It appears that not everything installed correctly though pip/pip3

tomsercu commented 2 years ago

From the paths in the logs, it seems like it's not picking up the right module installed in a conda/virtual environment, which would be in something like conda-env-dir/lib/python3.8/site-packages/. Can you try going to a different directory?

BenjyNStrauss commented 2 years ago

That didn't work. What did fix it was changing 'esm' to 'esm.data' "from esm.data import Alphabet"