属性错误:模块“streamlit”没有属性“chat_input”

问题描述 投票:0回答:1

我正在尝试在我的 conda 环境中运行一个简单的 Streamlit 应用程序。当我运行以下

app.py
文件时:

# Streamlit app
import streamlit as st

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

运行时返回以下错误

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'

我不明白为什么会发生这个错误。我使用的是最新的 Streamlit 版本。另外我不明白为什么错误使用 python3.9 而我在我的环境中使用 3.12 。我查看了这个博客,但不幸的是这没有帮助。所以我想知道是否有人知道为什么会发生这种情况?


我正在使用以下版本:

streamlit 1.30.0

还有蟒蛇:

python --version
Python 3.12.0
python python-3.x attributeerror streamlit
1个回答
0
投票

我在我的机器上安装了streamlit:

pip install streamlit==1.30.0

我可以确认

'chat_input'
存在于
streamlit==1.30.0

import streamlit as st
print('chat_input' in dir(st))

#输出

True

所以,我可以说你的 python 3.9 中有 Streamlit 版本 1.23.1 或更低版本

您可以使用python 3.9,但您需要找到正确的streamlit版本并升级它。

© www.soinside.com 2019 - 2024. All rights reserved.