# Streamlit "500 : Internal Server Error"

**URL:** <https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995>\
**Category:** Binder\
**Tags:** help-wanted\
**Created:** [September 15, 2020, 7:36pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995 "2020-09-15T19:36:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiago](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@Tiago](https://discourse.jupyter.org/u/Tiago)\
**Post date:** [September 15, 2020, 7:36pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/1 "2020-09-15T19:36:55Z")

</div>

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](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/](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.

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [September 15, 2020, 9:46pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/2 "2020-09-15T21:46:00Z")

</div>

Have you seen this [one](https://github.com/chekos/testing-streamlit-mybinder), 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/](https://mybinder.org/v2/gh/chekos/testing-streamlit-mybinder/master?urlpath=proxy/8501/)

Maybe it will help you debug yours?

---

<div class="post-metadata">

**Author:** ![Tiago](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@Tiago](https://discourse.jupyter.org/u/Tiago)\
**Post date:** [September 16, 2020, 1:39am UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/3 "2020-09-16T01:39:45Z")

</div>

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: 😄

# 404 : Not Found

You are requesting a page that does not exist!

Anyway, thanks for the note

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [September 16, 2020, 1:46pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/4 "2020-09-16T13:46:25Z")

</div>

Did you try forking the forking [the repo I referenced](https://github.com/chekos/testing-streamlit-mybinder) 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`.

---

<div class="post-metadata">

**Author:** ![Tiago](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@Tiago](https://discourse.jupyter.org/u/Tiago)\
**Post date:** [September 16, 2020, 9:14pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/5 "2020-09-16T21:14:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tiago](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@Tiago](https://discourse.jupyter.org/u/Tiago)\
**Post date:** [September 17, 2020, 4:39am UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/6 "2020-09-17T04:39:25Z")

</div>

Thank you very much @ [fomightez](https://discourse.jupyter.org/u/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?

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [September 17, 2020, 3:54pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/7 "2020-09-17T15:54:01Z")

</div>

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](https://discourse.jupyter.org/t/voila-usecase-when-waiting-on-user-input/4901/2).

---

<div class="post-metadata">

**Author:** ![Tiago](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@Tiago](https://discourse.jupyter.org/u/Tiago)\
**Post date:** [September 17, 2020, 6:33pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/8 "2020-09-17T18:33:06Z")

</div>

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](https://course.fast.ai/videos/?lesson=3), 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.

---

<div class="post-metadata">

**Author:** ![Tiago](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@Tiago](https://discourse.jupyter.org/u/Tiago)\
**Post date:** [September 20, 2020, 4:21am UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/9 "2020-09-20T04:21:35Z")

</div>

Hi, I fixed the issue, [here](https://discourse.jupyter.org/t/error-request-failed-with-status-code-403/6040) I explain what I did to fix the error message when loading an image into the app. This is the [link](https://mybinder.org/v2/gh/tiagogiraldo/sea_fish_recognition/master?urlpath=proxy/8501/), in case you want to explore the app already working correctly.

---

<div class="post-metadata">

**Author:** ![sgibson91](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sgibson91/32/487_2.png) [@sgibson91](https://discourse.jupyter.org/u/sgibson91)\
**Post date:** [October 7, 2020, 6:34am UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/11 "2020-10-07T06:34:21Z")

</div>

> [@Tiago](#):
>
> it did not accept that I added the version of Python that I require, (version 3.7 instead of 3.8)

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.

---

<div class="post-metadata">

**Author:** ![macromare](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/macromare/32/9296_2.png) [@macromare](https://discourse.jupyter.org/u/macromare)\
**Post date:** [March 6, 2023, 5:25pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/12 "2023-03-06T17:25:55Z")

</div>

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

- [https://mybinder.org/v2/gh/tiagogiraldo/sea\_fish\_recognition/master?urlpath=proxy/8501/](https://mybinder.org/v2/gh/tiagogiraldo/sea_fish_recognition/master?urlpath=proxy/8501/)
- [https://mybinder.org/v2/gh/chekos/testing-streamlit-mybinder/master?urlpath=proxy/8501/](https://mybinder.org/v2/gh/chekos/testing-streamlit-mybinder/master?urlpath=proxy/8501/)

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

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [March 6, 2023, 6:22pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/13 "2023-03-06T18:22:27Z")

</div>

I wonder if it is related to [the change in default server](https://discourse.jupyter.org/t/binder-switching-to-jupyter-server-by-default/18011)? 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](https://github.com/giswqs/streamlit-multipage-template) 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.

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [March 6, 2023, 7:19pm UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/14 "2023-03-06T19:19:30Z")

</div>

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

[https://mybinder.org/v2/gh/tiagogiraldo/sea\_fish\_recognition/master](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

```auto
less ~/.jupyter-server-log.txt 

```

in a JupyterLab terminal you’ll see an error

```auto
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).

```

---

<div class="post-metadata">

**Author:** ![macromare](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/macromare/32/9296_2.png) [@macromare](https://discourse.jupyter.org/u/macromare)\
**Post date:** [March 7, 2023, 10:06am UTC](https://discourse.jupyter.org/t/streamlit-500-internal-server-error/5995/15 "2023-03-07T10:06:09Z")

</div>

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.
