Streamlit "500 : Internal Server Error"

Hi, I’m newbie at binder, I made an api in streamlit, This can be seen in this repo: https://github.com/tiagogiraldo/sea_fish_recognition_stream. As url I writte “proxy/8501/”.

I’m following the instructions gived in https://pybonacci.org/2020/09/09/ejecutando-streamlit-usando-mybinder/ (it was written in spanish and the streamlit_pybo_article repo runs well in binder).

The only diference with streamlit_pybo_article structure is I’d not upload a environment.yml file (I tried but I get an conda update error message), so instead I’d upload a requeriment.txt file. I find the logs are all ok (maybe I could lost in traslation and I’m not finding any error), and I think the image was well built, but at the end I get this message error:

500 : Internal Server Error

I’ve read all the messages about it, but I haven’t been able to find one that helps me yet.

Have you seen this one, too? It uses requirements.txt like you tried and the link at the link bottom works:
https://mybinder.org/v2/gh/chekos/testing-streamlit-mybinder/master?urlpath=proxy/8501/

Maybe it will help you debug yours?

Thank you very much for your reply. It’s basically the same except for one instruction in the postBuild file, adding this line to the repo file and simplifying the requirements file, the results are the same. There is also a difference in the stream call file, the function is not called run, but the streamlit example Hello is called directly, ignoring the app name, but I don’t think this is what modifies the result.

Now the message is: :smile:

404 : Not Found

You are requesting a page that does not exist!

Anyway, thanks for the note

Did you try forking the forking the repo I referenced and changing URLs to see if the new version of that builds and things still work? That would help you know if it is something you’ve done (or are doing) or if something in the currently produced environment or build is bugged and the one I referenced only still works because it was using something built from earlier.

Once that is ruled out, I’d check your file hierarchy. I think only the things needed by binder should be in your .binder directory. I think you need several other files in root.

1 Like

Thanks for the feedback, I’ll follow your recommendations and see what happens!

Thank you very much @ fomightez for your help, now load the app. I did what you told me to do, making the fork of the repo you recommended and the other one I used as a guide to implement mine. I changed the respective links and they worked fine. Then I moved the files that were not needed in .binder to the root of my repo. Additionally I made a few modifications to the yml file, and this allowed the app to run in mybinder. Now the thing is that when I try to upload an image into the app, it results in another error that says

Error: Request failed with status code 403

Any suggestions?

So it wouldn’t work with requirements.txt?

Sorry, now that the basics work in MyBinder, I cannot be of much help. I haven’t tried Streamlit. I think that would be a Streamlit issue maybe or that part somehow not implemented in your app in conjunction with the Binder ecosystem? Have you come across any other examples that use file upload that would help?

Are you tied to using Streamlit as your app interface? I have used file upload for Voila apps, see here.

Yes, it does work with requeriments.txt. The reason for not using it is because when binder created the image, it did not accept that I added the version of Python that I require, (version 3.7 instead of 3.8). With these requirements it works the same as with the enviroment.yml.:

streamlit==0.66.0
jupyter-server-proxy==1.2.0
torch==1.6.0
torchvision==0.7.0
fastai==2.0.10

For conda to install the programs in the file yml I wrote this text in the file:

name: dl
channels:

  • conda
  • conda-forge
  • pytorch
    dependencies:
  • python=3.7.9
  • pip
  • jupyter-server-proxy
  • pytorch
  • torchvision
  • pip:
    • streamlit==0.66.0
    • fastai==2.0.10

What haven’t I been able to do yet? It’s getting pytorch not to install cuda, which in this case is redundant because it’s not going to run a net or anything, and it’s something I have to work on.

I agree with you about the problem with error 403, the problem may be with Streamlit, because I have not been able to get st.cache to work locally, or also with the Fastai load_learner function, or with both functions. I say this, or at least I intuit that it is because when I try to load an image for the model to evaluate, streamlit reloads the pkl again, and I think this is where the conflict can arise that causes the error to occur with binder, I repeat this is my intuition, and it is another thing that I must keep analyzing.

About whether I am obligated to work with Streamlit? Not really, I came to binder following the SFU course on deep learning, where they show how to make an application with Binder + Jupyter notebook + Voila. I liked the solution a lot, but the truth is that I think Streamlit is prettier, at least in appearance, that’s why my effort to get the app working with Streamlit and Binder.

Now I’m going to implement a dashboard using Scikit Learn, something I didn’t load a model like the pkl in this app, and see what else I can learn from the interaction between binder and streamlit, and rule out problems. Again thank you very much for the indications of yesterday, otherwise it would be bogging down still, if I do not leave just the essential files in the folder .binder , I think I would be very frustrated, at least now I know that the app uploads, and that is already gain for me.

1 Like

Hi, I fixed the issue, here I explain what I did to fix the error message when loading an image into the app. This is the link, in case you want to explore the app already working correctly.

1 Like

This is a ‘catch-all’ error generated by the Web server. The first thing you need to know about an “Internal Server Error” is that the error can only be resolved by fixes to the Web server software. It is not a client-side problem meaning that the problem is not with your browser, your computer, or your internet connection. 500 Internal Server Error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. However, there are often ways to quickly get around the problem:

  • Very commonly, incorrect permissions on a file or folder that contains one of the scripts causes this this error.
  • Reload your browser (press F5) or try with another one. The chances that the page will load when you refresh your browser are low, but still, it’s worth giving it a try.
  • Try to clear your browser cache. If the page that shows 500 error is cached, after the cache is cleared, the browser will request a new version of the page.
  • Come back later. The webmaster may fix the server issue in the meantime.
  • A Coding Error in .htaccess. While not as common, be sure to check that your site’s .htaccess file is properly structured.
  • Contact the website owners. The last remaining option is to get in touch with the person responsible for maintaining the website.

You’ve got it to work so this is for information only. A runtime.txt file containing python-3.7 on a single line would have resolved this.

1 Like