TypeError: Descriptors cannot not be created directly

I get the following error when deploying the app. I dont use the package mentioned in the erorr, any ideas?

Error:

❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.
Traceback (most recent call last):
  File "/home/appuser/venv/bin/streamlit", line 5, in <module>
    from streamlit.cli import main
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/__init__.py", line 48, in <module>
    from streamlit.proto.RootContainer_pb2 import RootContainer
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/proto/RootContainer_pb2.py", line 33, in <module>
    _descriptor.EnumValueDescriptor(
  File "/home/appuser/venv/lib/python3.9/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).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
4 Likes

I’m seeing the exact same error when trying to deploy an app. Was working fine yesterday and then this evening it started failing.

1 Like

same here

Yes, I got the same error as well and just could not solve it , would be great if anyone can share how to overcome this problem.

Hi all :wave:

It looks like a breaking change in one of Streamlit library’s dependencies (protobuf) is the cause of this issue. I’ve notified the team who are working on a fix. A patch to fix this issue will be included in our release next week.

Until then, a temporary solution (thanks @whitphx!) is to include the following in your requirements.txt:

protobuf~=3.19.0

Best, :balloon:
Snehan

5 Likes

Thank you Snehan for the clarification!

Unfortunately , I still had that error during deployment even when I included protobuf~=3.19.0 in my requirements.txt.

Thank you!! I got the same problem and adding that in requeriments.txt solve the issue.

3 Likes

@SiewPingYeo, your file is incorrectly named streamlit requirements.txt, instead of requirements.txt.

I would also suggest cleaning up that file to only include packages used in your app (in addition to protobuf~=3.19.0), as opposed to exporting all packages in your local Python environment.

Should streamlit pin dependencies to specific versions that are known to work? That would avoid surprises like this where an update to a dependency starts causing problems out of the blue.

2 Likes

Thank you! Problem solved :slight_smile:

1 Like

Even after adding protobuf~=3.19.0 to requirements.txt, i’m still facing this error.

Hi @Radheshyamvaishnav :wave:

When you don’t include streamlit in your requirements file, Streamlit Cloud installs the latest available version of Streamlit and and keeps that version installed for the lifetime of the app, regardless of whether you later include streamlit in your requirements. We should better document this behaviour in our docs.

I would suggest you:

  1. Delete your app on Streamlit Cloud (important)
  2. Add streamlit==1.9.0 (in addition to protobuf~=3.19.0) in your requirements.txt
  3. Re-deploy your app
1 Like

adding protobuf~=3.19.0 to requirements.txt + rebooting the app worked for me

I hope it’s possible to add some test coverage to prevent this from recurring, had a really confusing/classic “but it works on my machine” moment :troll:

2 Likes

Thanks @snehankekre

Hi!

Having similar issues, but where can I find requirements.txt? Tried looking for it but can’t find it. Using an environment

Then you’ll need to create the file yourself @kbbln.

Thanks a lot. This is quite helpful!

For anyone who is looking for a proper solution,

answer:- https://stackoverflow.com/a/72493690/6194097

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.