我正在尝试在 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
我在我的机器上安装了streamlit:
我可以确认它
'chat_input'
存在于streamlit==1.30.0
#输出
所以,我可以说你的 python 3.9 中有 Streamlit 版本 1.23.1 或更低版本
您可以使用 python 3.9,但您需要找到正确的 Streamlit 版本并升级它。
创建一个新的虚拟环境:
激活虚拟环境:
然后安装
streamlit
:然后你可以运行你的应用程序:
这样您就可以确保您使用的是正确版本的
streamlit
.您可以使用conda 来管理管理环境