ModuleNotFoundError: No module named 'frontend'

i am trying to deploy app which contain some module like fitz , pandas and so on. There is a package named fitz on PyPI. Because PyMuPDF uses the same name, fitz , as its top-level text, both packages cannot co-exist in the same Python - except with the aforementioned change. So it gives me error like this ModuleNotFoundError: No module named ‘frontend’.

Hi @Kayshika_Code, welcome to the Streamlit community!! :wave: :partying_face:

There are series of changes you need to make to successfully deploy your app:

  1. Remove fitz==0.0.1.dev2 from line 1 of requirements.txt. It is an outdated package that has been replaced by PyMuPDF.
  2. From reading the med7 docs, you’ll see that you need to include a line in requirements.txt containing https://huggingface.co/kormilitzin/en_core_med7_lg/resolve/main/en_core_med7_lg-any-py3-none-any.whl
  3. Update line 4 to read: spacy==3.1.4 . The med7 model :point_up: from Step 2 depends on spacy < 3.2.0 and >=3.1.4.
  4. Replace the image paths in App.py with just the image names. eg: Image.open('image-1.png'). Recall that Streamlit Cloud is unaware of the directory structure of your local machine.
  5. As the model from Step 2 is large (700+ MB), you should cache the model with st.experimental_singleton to reuse the same model across users and app reruns, and prevent exhausting your app resources. Define the following function outside of main():
@st.experimental_singleton
def load_model():
    nlp = spacy.load("en_core_med7_lg")
    return nlp
  1. In your main() method, replace nlp = spacy.load("en_core_med7_lg") with nlp = load_model()

For reference, a fork with the above changes is here: GitHub - snehankekre/Drug-Entity-Extractor

Once you make the above changes, your app should successfully deploy! :rocket:

Happy Streamlit-ing! :balloon:
Snehan

2 Likes

After completed, in right side terminal i didn’t see any url that i can share to people.