question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to import esm

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tomsercucommented, Aug 24, 2022

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.

0reactions
pengzhangzhicommented, Aug 24, 2022

Problem solved! Happy to see that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to import ESM .ts module in node - Stack Overflow
You can't import .ts files direct in NodeJS, you need to first transpile it using tsc to then import it in the NodeJS...
Read more >
Unable to import from libs using ESM #109 - remix-run/remix
The following error is thrown when trying to import from libs using ESM (like unist-util-visit): Error [ERR_REQUIRE_ESM]: Must use import to load ES...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live ... The importing module can only read the value but can't re-assign it....
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Caveat: The ESM load hook and namespaced exports from CommonJS modules are incompatible. Attempting to use them together will result in an empty...
Read more >
Gotchas - Remix
For example, you can't import "fs-extra" directly into a route module: ... You may try importing an ESM-only package into your app and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found