I keep getting ModuleNotFoundError during deploying my app

Public app - https://leafdisease.streamlit.app/
Github repo - GitHub - PranjalAsthana/Plant-Leaf-Disease-Classification-Using-CNN

I keep getting this error ““import tensorflow as tf ModuleNotFoundError: No module named ‘tensorflow’”” which is the only reason holding back my app from running. I have tried every solution on the web but nothing seems to work. There is no problem with my local machine either. It works fine on my local machine.

When using pip freeze requirements.txt I was getting 201 libraries which would crash the app, so I took out the file and replaced it with only the required files. Now I get error in importing tensorflow. The app works completely on local machine, no errors whatsoever.

Please take a look and help me out with this problem.

Full Error Traceback -

File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)File "/mount/src/plant-leaf-disease-classification-using-cnn/plantdiseaseapp.py", line 2, in <module>
    import tensorflow as tf

Panel text -

Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/plant-leaf-disease-classification-using-cnn/plantdiseaseapp.py", line 2, in <module>
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
2023-12-15 18:58:03.803 503 GET /script-health-check (10.12.100.81) 135.21ms

Streamlit ver-1.28.1
Python ver-3.115

  • This file is NOT in your github repo, therefore dependencies cannot be installed on streamlit cloud.
  • Write it manually and only include those dependencies that you actually import in your streamlit app.

Thank you for replying. Adding requirements.txt gave another error as stated above so I had removed it. I have added it again and the app problem persists. Please tell what to do now.

Here is the new error message

ERROR: Could not find a version that satisfies the requirement tensorflow-intel==2.12.0 (from versions: 0.0.1)
ERROR: No matching distribution found for tensorflow-intel==2.12.0
WARNING: You are using pip version 22.0.3; however, version 23.3.1 is available.
You should consider upgrading via the '/home/adminuser/venv/bin/python -m pip install --upgrade pip' command.
Checking if Streamlit is installed

────────────────────────────────────────────────────────────────────────────────────────

[11:25:03] ❗️ installer returned a non-zero exit code
[11:25:03] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.

After removing tensorflow-intel from requirements.txt, I am getting this new error message

Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/plant-leaf-disease-classification-using-cnn/plantdiseaseapp.py", line 6, in <module>
    import cv2
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
2023-12-16 11:29:54.160 503 GET /script-health-check (10.12.232.252) 114.58ms

requirements.txt

numpy
pillow
tensorflow
streamlit

…and remove import cv2 from your app code, you don’t use it…

Ok I’ll check and report back to you.

Thank you so much it works now. Can I commend you some way?