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

unable to import esm #257

Closed
pengzhangzhi opened this issue Aug 23, 2022 · 8 comments
Closed

unable to import esm #257

pengzhangzhi opened this issue Aug 23, 2022 · 8 comments
Assignees

Comments

@pengzhangzhi
Copy link

I install by pip install fair-esm.
Then try the example code:

import torch
import esm

# Load ESM-2 model
model, alphabet = esm.pretrained.esm2_t48_15B_UR50D()
batch_converter = alphabet.get_batch_converter()
model.eval()  # disables dropout for deterministic results

The following error is raised:

ModuleNotFoundError                       Traceback (most recent call last)
Untitled-1.ipynb Cell 1 in <cell line: 2>()
      [1](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=0) import torch
----> [2](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=1) import esm
      [4](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=3) # Load ESM-2 model
      [5](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=4) model, alphabet = esm.pretrained.esm2_t48_15B_UR50D()

File ~/anaconda3/envs/torch/lib/python3.8/site-packages/esm/__init__.py:9, in <module>
      6 from .version import version as __version__  # noqa
      8 from .data import Alphabet, BatchConverter, FastaBatchedDataset  # noqa
----> 9 from .model.esm1 import ProteinBertModel  # noqa
     10 from .model.esm2 import ESM2  # noqa
     11 from .model.msa_transformer import MSATransformer  #noqa

ModuleNotFoundError: No module named 'esm.model.esm1'; 'esm.model' is not a package
@ptynecki
Copy link

@pengzhangzhi Reinstall the package from main branch.

@tomsercu
Copy link
Contributor

Yes it sounds like a version conflict. Can you pip uninstall and then pip install again and make sure the version is 1.0.2 which just appeared on pip today?

@pengzhangzhi
Copy link
Author

Seems like the version I install is just 1.0.2. I just install the pkg and find this error. After uninstall and re-install with pip install fair-esm==1.0.2. The same problem still show up.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Untitled-1.ipynb Cell 1 in <cell line: 2>()
      [1](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=0) import torch
----> [2](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=1) import esm
      [4](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=3) # Load ESM-2 model
      [5](vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D?line=4) model, alphabet = esm.pretrained.esm2_t48_15B_UR50D()

File ~/anaconda3/envs/torch/lib/python3.8/site-packages/esm/__init__.py:9, in <module>
      6 from .version import version as __version__  # noqa
      8 from .data import Alphabet, BatchConverter, FastaBatchedDataset  # noqa
----> 9 from .model.esm1 import ProteinBertModel  # noqa
     10 from .model.esm2 import ESM2  # noqa
     11 from .model.msa_transformer import MSATransformer  #noqa

ModuleNotFoundError: No module named 'esm.model.esm1'; 'esm.model' is not a package

@donovanr
Copy link

donovanr commented Aug 23, 2022

I also have this problem, installing from main and also from pypi with fair-esm==1.0.2 into a fresh conda env with python=3.9 on linux:

Error message
In [1]: import torch

In [2]: import esm
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 import esm

File ~/mambaforge/envs/fairesm/lib/python3.9/site-packages/esm/__init__.py:9, in <module>
      6 from .version import version as __version__  # noqa
      8 from .data import Alphabet, BatchConverter, FastaBatchedDataset  # noqa
----> 9 from .model.esm1 import ProteinBertModel  # noqa
     10 from .model.esm2 import ESM2  # noqa
     11 from .model.msa_transformer import MSATransformer  #noqa

ModuleNotFoundError: No module named 'esm.model.esm1'; 'esm.model' is not a package
Environment The result of
conda create -n fairesm python=3.9
conda activate fairesm
pip install torch ipykernel
pip install fair-esm==1.0.2
conda list
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
asttokens                 2.0.8                    pypi_0    pypi
backcall                  0.2.0                    pypi_0    pypi
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.6.15            ha878542_0    conda-forge
debugpy                   1.6.3                    pypi_0    pypi
decorator                 5.1.1                    pypi_0    pypi
entrypoints               0.4                      pypi_0    pypi
executing                 0.10.0                   pypi_0    pypi
fair-esm                  1.0.2                    pypi_0    pypi
ipykernel                 6.15.1                   pypi_0    pypi
ipython                   8.4.0                    pypi_0    pypi
jedi                      0.18.1                   pypi_0    pypi
jupyter-client            7.3.4                    pypi_0    pypi
jupyter-core              4.11.1                   pypi_0    pypi
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 12.1.0              h8d9b700_16    conda-forge
libgomp                   12.1.0              h8d9b700_16    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libsqlite                 3.39.2               h753d276_1    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.12               h166bdaf_2    conda-forge
matplotlib-inline         0.1.6                    pypi_0    pypi
ncurses                   6.3                  h27087fc_1    conda-forge
nest-asyncio              1.5.5                    pypi_0    pypi
openssl                   3.0.5                h166bdaf_1    conda-forge
packaging                 21.3                     pypi_0    pypi
parso                     0.8.3                    pypi_0    pypi
pexpect                   4.8.0                    pypi_0    pypi
pickleshare               0.7.5                    pypi_0    pypi
pip                       22.2.2             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.30                   pypi_0    pypi
psutil                    5.9.1                    pypi_0    pypi
ptyprocess                0.7.0                    pypi_0    pypi
pure-eval                 0.2.2                    pypi_0    pypi
pygments                  2.13.0                   pypi_0    pypi
pyparsing                 3.0.9                    pypi_0    pypi
python                    3.9.13          h2660328_0_cpython    conda-forge
python-dateutil           2.8.2                    pypi_0    pypi
python_abi                3.9                      2_cp39    conda-forge
pyzmq                     23.2.1                   pypi_0    pypi
readline                  8.1.2                h0f457ee_0    conda-forge
setuptools                65.2.0           py39hf3d152e_0    conda-forge
six                       1.16.0                   pypi_0    pypi
sqlite                    3.39.2               h4ff8645_1    conda-forge
stack-data                0.4.0                    pypi_0    pypi
tk                        8.6.12               h27826a3_0    conda-forge
torch                     1.12.1                   pypi_0    pypi
tornado                   6.2                      pypi_0    pypi
traitlets                 5.3.0                    pypi_0    pypi
typing-extensions         4.3.0                    pypi_0    pypi
tzdata                    2022c                h191b570_0    conda-forge
wcwidth                   0.2.5                    pypi_0    pypi
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge

@dikshyantg
Copy link

I also have a similar problem when I try to run the extract.py script

File "/home/dikshyant/anaconda3/lib/python3.7/site-packages/esm/init.py", line 9, in
from .model.esm1 import ProteinBertModel # noqa
ModuleNotFoundError: No module named 'esm.model.esm1'; 'esm.model' is not a package

@pooriyapfn
Copy link

I had this issue too, but I could run it with a trick.
first of all uninstall your package and use this command:

pip install git+https://github.com/facebookresearch/esm.git

after that if you are using Jupyter (like colab), first run this block of code, to download the model completely:

import torch
import esm

model, alphabet = esm.pretrained.esm2_t36_3B_UR50D()

after several minutes you can run rest of your code.

Screen Shot 1401-06-02 at 3 02 41 PM

@tomsercu
Copy link
Contributor

Hi folks thanks for flagging this issue. The build was broken due to an old file (model.py) accidentally being included in the pip wheel. Note that there was no issue on the github main branch, so as @pooriyapfn points out pip install git+https://github.com/facebookresearch/esm.git still worked.

The wheel is fixed now, so please go ahead and pip uninstall, then pip install fair-esm or pip install fair-esm==1.0.2.

Sorry for the inconvenience.

@pengzhangzhi
Copy link
Author

Problem solved! Happy to see that!

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

6 participants