Protobuf 3.20.1 which is incompatible

Summary

I’m trying to deploy an app with tensorflow but I keep getting an error from protobuf incompatibility.

Steps to reproduce

Code snippet:


Installing collected packages: protobuf

  Attempting uninstall: protobuf

    Found existing installation: protobuf 3.19.6

    Uninstalling protobuf-3.19.6:

      Successfully uninstalled protobuf-3.19.6

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.

tensorflow 2.10.0 requires protobuf<3.20,>=3.9.2, but you have protobuf 3.20.1 which is incompatible.

tensorboard 2.10.1 requires protobuf<3.20,>=3.9.2, but you have protobuf 3.20.1 which is incompatible.

Successfully installed protobuf-3.20.1

Debug info

1 Like

Hi @Vincent_Terrasi :wave:

Please share a link to your GitHub repo and the contents of your requirements file. Your app isn’t publicly accessible. Moreover, the warning from pip is prescriptive in terms of what you need to do. Install protobuf<3.20,>=3.9.2.

Also, if Streamlit Cloud is installing protobuf-3.20.1, and you continue to see the pip warnings, you can safely ignore them. TensorFlow and TensorBoard can still be imported and work without errors.

1 Like

Thanks for your answer.

Our repo is here : GitHub - voltek62/codex-for-seo
I worked with Charly Wargnier

The requirements file is surely the most difficult task to adapt for deploying an app :slight_smile:

(https://github.com/voltek62/codex-for-seo/blob/main/requirements.txt)

Thanks for sharing your requirements file. You can feel free to ignore the warnings generated by pip in this instance. Are you not able to import tensorflow and tensorboard and run them? I was able to import tensorflow inspite of the warnings with: :thinking:

streamlit==1.13.0
tensorflow==2.10.0
tensorboard==2.10.1

Side note: fbprophet cannot unfortunately be installed on Community Cloud due to resource limit exhaustion (OOM killed) when the library’s dependencies are being compiled. The same is true for face-recognition. :disappointed:

So I personalized the URL: https://codex-for-seo.streamlitapp.com/
And now the app is visible to anyone with the link

In fact, the original error is : ModuleNotFoundError: No module named ‘streamlit.scriptrunner’
And I thought, it was related to TensorFlow installation.

Do you have any ideas to help me ?

So here’s the entire traceback:

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 562, in _run_script
    exec(code, module.__dict__)
File "/app/codex-for-seo/streamlit_app.py", line 3, in <module>
    from streamlit_gallery import apps
File "/app/codex-for-seo/streamlit_gallery/apps/__init__.py", line 3, in <module>
    from .m2_codex_data import main as m2_codex_data
File "/app/codex-for-seo/streamlit_gallery/apps/m2_codex_data.py", line 26, in <module>
    from streamlit.scriptrunner.script_run_context import get_script_run_ctx

Your code in codex-for-seo/streamlit_gallery/apps/m2_codex_data.py seems to be using an internal (subject to change without deprecation!) API that no longer exists in Streamlit 1.13.0.

You have two options.

  1. Either downgrade to an older version that does contain the method, or
  2. Wait for the next release on the 27th and modify your code accordingly to use a new “internal” (i.e.: subject to change without deprecation!) API to access a copy of the headers from the current session’s incoming WebSocket request; described in this thread:Streamlit.scriptrunner on streamlit 1.13.0 and GitHub issue: _get_websocket_headers() by tconkling · Pull Request #5457 · streamlit/streamlit · GitHub

Also, read this GitHub issue for more context on the relocation of scriptrunner to the streamlit.runtime module

@Vincent_Terrasi

The third option (while waiting for the next release) is to install streamlit-nightly and modify your _get_session() method to the following:

from streamlit.runtime.scriptrunner import get_script_run_ctx

import streamlit as st
from streamlit import runtime


def _get_session():
    ctx = get_script_run_ctx()
    if ctx is None:
        return None

    session_client = runtime.get_instance().get_client(ctx.session_id)
    if session_client is None:
        return None

    return session_client._session_id


st.write(_get_session())

I downgraded to streamlit 1.12 and still the same issue.
What is the best version for the current code ?

I’m not sure. You’ll have to go through the codebase to find out as it was an internal API. Until the next release, you could try using the code from my previous reply and streamlit-nightly. Else, you’ll have to find the appropriate version yourself either via going through the codebase or trial and error.

Yes, it works/
I downgraded to streamlit 1.11

But now , I found a new limitation for writing a file directly in my apps Streamlit.

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 557, in _run_script
    exec(code, module.__dict__)
File "/app/codex-for-seo/streamlit_app.py", line 107, in <module>
    main()
File "/app/codex-for-seo/streamlit_app.py", line 90, in main
    page_selected()
File "/app/codex-for-seo/streamlit_gallery/apps/m2_codex_data.py", line 214, in main
    out, error, code, prompt = execute(data, text, datapath)
File "/app/codex-for-seo/streamlit_gallery/apps/m2_codex_data.py", line 95, in execute
    with open(scriptpath, "w") as f:

Do you have any suggestions ?
In local mode, I have no issues.