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

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

Some time later, I find that all of these produce the same error as the OP has stated:

Can anyone help me to find out what’s broken here? Trying to transition a streamlit app to mybinder and also obtaining the 500 internal server error…

@fomightez

I wonder if it is related to the change in default server? Unfortunately, I hadn’t tried any related repos recently.

I do note that GitHub - giswqs/streamlit-multipage-template: A streamlit multipage app template for geospatial applications had been worked on; however, even though there is a launch binder badge featured prominently, I cannot be sure it was tested four months ago.

1 Like

The default server is only updated in the BinderHub code base, it hasn’t been updated on mybinder.org yet (though it will be soon).

https://mybinder.org/v2/gh/tiagogiraldo/sea_fish_recognition/master works fine if you don’t specify the urlpath, i.e. jupyterlab lab is running fine.

If you run

less ~/.jupyter-server-log.txt 

in a JupyterLab terminal you’ll see an error

Traceback (most recent call last):
  File "/srv/conda/envs/notebook/bin/streamlit", line 5, in <module>
    from streamlit.cli import main
  File "/srv/conda/envs/notebook/lib/python3.7/site-packages/streamlit/__init__.py", line 99, in <module>
    from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
  File "/srv/conda/envs/notebook/lib/python3.7/site-packages/streamlit/delta_generator.py", line 25, in <module>
    from streamlit.proto import BlockPath_pb2
  File "/srv/conda/envs/notebook/lib/python3.7/site-packages/streamlit/proto/BlockPath_pb2.py", line 38, in <module>
    create_key=_descriptor._internal_create_key),
  File "/srv/conda/envs/notebook/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
2 Likes

Thanks, I’ve also noticed that I can run Jupyterlab. But the app is supposed to be used by users w/o coding experience. I would like to transition several apps to mybinder (binderhub in the long run), including a streamlit app, so any help in resolving this problem is much appreciated. I will take a look at the server log.