Import Cv2 error can’t solve by adding opencv headless to requirments.txt

I am deploying streamlit app on streamlit cloud. the app uses opencv and mediapipe … i can not solve this error . Can anyone help me solve the below issue

Libraries used
Screenshot (272)


Hi @karim-abdulnabi . Instead of opencv-python-headless use opencv-python-contrib-headless.

@Guna_Sekhar_Venkata . I changed it but not work also

hi @karim-abdulnabi . could you share the code block of error?

hey @karim-abdulnabi i have seen your github repo. You mentioned requirements.txt file in Sing_Language_Project/st_project/requirements.txt. Instead of there, move it to the root directory (Sing_Language_Project) where streamlit can first see the requirements.txt before building the app. So move requirements.text to the root folder named Sing_Language_Project.

      --- requirements.txt
      --- rest of the sub directories

Use the follows names in your requirements.txt as follows:


![Screenshot (1)|690x388](upload://qEuFWpeE0JeAKBEH8hgQ8iXILMU.png)

After implementing the modifications, the same problem appears

sorry i have shared wrong directory structure. Follow:

      --- requirements.txt
      --- Sing_Language_Project

the same error

@karim-abdulnabi , You are using which python version of your cloud and what is the use of tensorflow-cpu pacakge?

python 3.10.9
cv2 4.9.0
streamit 1.31.1

Hey @karim-abdulnabi delete the app once and redeploy the app by selecting the python version as 3.9. Don’t mention any specific version of package in the requirements.txt file. Im hoping that it should work now.

Happy Streamlit-ing :balloon:

@Guna_Sekhar_Venkata , not work But a change in error

  • Remove opencv from the requirements file, it is useless in this specific case, because mediapipe overrules this anyway and enforces the installation of a non-headless opencv version.
  • I think there are still missing dependencies in the requirements file.
  • Move both packages.txt and requirements.txt to the root folder of the github repo.
  • Do a reboot of the streamlit app

@Franky1 , Yes, there were some requirements that I added, but they did not work either