pythonpython-3.xpipattributeerrorstreamlit

AttributeError: module 'streamlit' has no attribute 'chat_input'


I'm trying to run a simple Streamlit app in my conda env. When I'm running the following app.py file:

# Streamlit app
import streamlit as st

# 
prompt = st.chat_input("Say something")
if prompt:
    st.write(f"User has sent the following prompt: {prompt}")

It returns the following error when running streamlit run app.py:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 556, in _run_script
    exec(code, module.__dict__)
  File "/Users/quinten/Documents/app.py", line 11, in <module>
    prompt = st.chat_input("Say something")
AttributeError: module 'streamlit' has no attribute 'chat_input'

I don't understand why this error happens. I used the newest Streamlit version. Also I don't understand why the error uses python3.9 while I use 3.12 in my environment. I check this blog, but this doesn't help unfortunately. So I was wondering if anyone knows why this happens?


I'm using the following versions:

streamlit 1.30.0

And python:

python --version
Python 3.12.0

Solution

  • Create a new virtual environment:

    python -m venv venv
    

    Activate the virtual environment :

    source venv/bin/activate
    

    Then install streamlit:

    pip install streamlit
    

    Then you can run your app:

    streamlit run app.py
    

    That way you can make sure that you are using the right version of streamlit.

    You can use conda to manage manage environments