Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

streamlit exited with code 1 due to TypeError in python3.7/site-packages/google/protobuf/descriptor.py #23

Closed
slowglow opened this issue Jul 7, 2022 · 1 comment · Fixed by #24

Comments

@slowglow
Copy link

slowglow commented Jul 7, 2022

Thanks for the example of how to tie up FastAPI and streamlit in docker.

On two of my machines streamlit exited with code 1, as mentioned in the title.
The full trace is pasted below.
The solution I found was to upgrade the packages in streamlit/requirements.txt to their most recent versions:

-- original requirements.txt ---

streamlit==1.9.0 
requests==2.24.0
requests-toolbelt==0.9.1

-- modified requirements.txt ---

streamlit==1.10.0 
requests==2.28.1
requests-toolbelt==0.9.1

--- Screen output---

~/Downloads/streamlit-fastapi$ docker-compose up
Creating network "streamlit-fastapi_deploy_network" with driver "bridge"
Creating fastapi ... done
Creating streamlit ... done
Attaching to fastapi, streamlit
streamlit    | Traceback (most recent call last):
streamlit    |   File "/usr/local/bin/streamlit", line 5, in <module>
streamlit    |     from streamlit.cli import main
streamlit    |   File "/usr/local/lib/python3.7/site-packages/streamlit/__init__.py", line 48, in <module>
streamlit    |     from streamlit.proto.RootContainer_pb2 import RootContainer
streamlit    |   File "/usr/local/lib/python3.7/site-packages/streamlit/proto/RootContainer_pb2.py", line 37, in <module>
streamlit    |     create_key=_descriptor._internal_create_key),
streamlit    |   File "/usr/local/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 755, in __new__
streamlit    |     _message.Message._CheckCalledFromGeneratedFile()
streamlit    | TypeError: Descriptors cannot not be created directly.
streamlit    | 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.
streamlit    | If you cannot immediately regenerate your protos, some other possible workarounds are:
streamlit    |  1. Downgrade the protobuf package to 3.20.x or lower.
streamlit    |  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
streamlit    | 
streamlit    | More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
streamlit exited with code 1
fastapi      | Downloading: "https://github.com/pytorch/vision/archive/v0.6.0.zip" to /root/.cache/torch/hub/v0.6.0.zip
fastapi      | Downloading: "https://download.pytorch.org/models/resnet101-5d3b4d8f.pth" to /root/.cache/torch/hub/checkpoints/resnet101-5d3b4d8f.pth
100.0%i      | 
fastapi      | Downloading: "https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth" to /root/.cache/torch/hub/checkpoints/deeplabv3_resnet101_coco-586e9e4e.pth
100.0%i      | 
fastapi      | INFO:     Started server process [1]
fastapi      | INFO:     Waiting for application startup.
fastapi      | INFO:     Application startup complete.
fastapi      | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
fastapi      | INFO:     172.19.0.1:51794 - "GET / HTTP/1.1" 404 Not Found
@davidefiocco
Copy link
Owner

davidefiocco commented Jul 9, 2022

Hey, thanks for flagging this and suggesting the solution.
The problem is related to this https://stackoverflow.com/questions/72441758/typeerror-descriptors-cannot-not-be-created-directly/72493690#72493690
The main branch has been updated accordingly with #24
Can reopen this if the problem occurs again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants