我正在尝试在我的 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 。我检查这个blog ,但不幸的是这没有帮助。所以我想知道是否有人知道为什么会发生这种情况?
我正在使用以下版本:
streamlit 1.30.0
还有Python:
python --version
Python 3.12.0
最佳答案
创建一个新的virtual environment :
python -m venv venv
激活虚拟环境:
source venv/bin/activate
然后安装streamlit
:
pip install streamlit
然后您可以运行您的应用程序:
streamlit run app.py
这样您就可以确保您使用的是正确版本的 streamlit
。
您可以使用conda管理管理环境
关于python - 属性错误:模块 'streamlit' 没有属性 'chat_input',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77819377/