Streamlit:如何正确地将我的 python 包添加到 requirements.txt?
Streamlit: How do I correctly add my python packages to the requirements.txt?
我想试用 Streamlit 共享 (https://www.streamlit.io/sharing)。这是我的本地工作代码:
streamlit_app.py
import pandas as pd
import streamlit as st
from PIL import Image
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
# Model
df = pd.read_csv("IRIS.csv")
X = df.drop(columns=["species"])
y = df["species"]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
rf = RandomForestClassifier()
rf.fit(X_train, y_train)
# Streamlit
st.header("Iris Classification")
image = Image.open("iris.jpg")
st.image(image, use_column_width=True, output_format="jpg")
st.write("Please insert values, to get Iris class prediction")
SepalLengthCm = st.slider('SepalLengthCm:', 2.0, 6.0)
SepalWidthCm = st.slider('SepalWidthCm:', 0.0, 5.0)
PetalLengthCm = st.slider('PetalLengthCm',0.0, 3.0)
PetalWidthCm = st.slider('PetalWidthCm:', 0.0, 2.0)
data = {'SepalLengthCm': SepalLengthCm,
'SepalWidthCm': SepalWidthCm,
'PetalLengthCm': PetalLengthCm,
'PetalWidthCm': PetalWidthCm}
features = pd.DataFrame(data, index=[0])
prediction = rf.predict(features)
percentages = rf.predict_proba(features)
st.subheader("Prediction")
st.write(prediction[0])
st.subheader("Percentages")
st.write("Iris-setosa: ", percentages[0][0]*100)
st.write("Iris-versicolor: ", percentages[0][1]*100)
st.write("Iris-virginica: ", percentages[0][2]*100)
现在,为了获得 requirements.txt(流媒体共享所必需的),我执行了以下操作:
- 使用
conda create --name streamlit-test python=3.7
创建新环境
pip install streamlit
pip install sklearn
- 可选:
streamlit run streamlit_app.py
在本地成功运行应用程序
pip freeze > requirements.txt
当我通过 Streamlit 共享部署应用程序时,它显示“ModuleNotFoundError:没有名为 'sklearn' 的模块”(第 5 行)。您实际上应该能够自己看到这个:https://share.streamlit.io/juliangermek/streamit_test
检查 requirements.txt 显示 sklearn 像这样存在 sklearn==0.0
。
这是来自 Streamlit Sharing 的日志:
[client] Connecting...
[manager] Starting up for owner: 'juliangermek', repository: 'streamit_test', branch: 'master', main module: 'streamlit_app.py'
[manager] Cloning repository ...
[manager] Cloning into 'streamit_test'...
[manager] Cloned repository!
[manager] Processing dependencies ...
Requirement already satisfied: altair==4.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (4.1.0)
ERROR: Could not find a version that satisfies the requirement anaconda-client==1.7.2
ERROR: No matching distribution found for anaconda-client==1.7.2
[manager] Processed dependencies!
You can now view your Streamlit app in your browser.
Network URL: http://10.12.4.85:8501
External URL: [2021-01-22 07:46:22.016741] http://35.230.58.211:8501
Requirement already satisfied: altair==4.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (4.1.0)
ERROR: Could not find a version that satisfies the requirement anaconda-client==1.7.2
ERROR: No matching distribution found for anaconda-client==1.7.2
Stopping...
You can now view your Streamlit app in your browser.
Network URL: http://10.12.4.85:8501
External URL: http://35.230.58.211:8501
Requirement already satisfied: altair==4.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (4.1.0)
Requirement already satisfied: argon2-cffi==20.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (20.1.0)
Requirement already satisfied: astor==0.8.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (0.8.1)
Requirement already satisfied: async-generator==1.10 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (1.10)
Requirement already satisfied: attrs==20.3.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (20.3.0)
Requirement already satisfied: backcall==0.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (0.2.0)
Requirement already satisfied: base58==2.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 7)) (2.1.0)
Requirement already satisfied: bleach==3.2.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (3.2.2)
Requirement already satisfied: blinker==1.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 9)) (1.4)
Requirement already satisfied: cachetools==4.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 10)) (4.2.0)
Requirement already satisfied: certifi==2020.12.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 11)) (2020.12.5)
Requirement already satisfied: cffi==1.14.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 12)) (1.14.4)
Requirement already satisfied: chardet==4.0.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 13)) (4.0.0)
Requirement already satisfied: click==7.1.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 14)) (7.1.2)
Requirement already satisfied: decorator==4.4.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 16)) (4.4.2)
Requirement already satisfied: defusedxml==0.6.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 17)) (0.6.0)
Requirement already satisfied: entrypoints==0.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 18)) (0.3)
Requirement already satisfied: gitdb==4.0.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 19)) (4.0.5)
Requirement already satisfied: GitPython==3.1.12 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 20)) (3.1.12)
Requirement already satisfied: idna==2.10 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 21)) (2.10)
Requirement already satisfied: importlib-metadata==3.4.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 22)) (3.4.0)
Requirement already satisfied: ipykernel==5.4.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 23)) (5.4.3)
Requirement already satisfied: ipython==7.19.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 24)) (7.19.0)
Requirement already satisfied: ipython-genutils==0.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 25)) (0.2.0)
Requirement already satisfied: ipywidgets==7.6.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 26)) (7.6.3)
Requirement already satisfied: jedi==0.18.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 27)) (0.18.0)
Requirement already satisfied: Jinja2==2.11.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 28)) (2.11.2)
Requirement already satisfied: jsonschema==3.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 30)) (3.2.0)
Requirement already satisfied: jupyter-client==6.1.11 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 31)) (6.1.11)
Requirement already satisfied: jupyter-core==4.7.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 32)) (4.7.0)
Requirement already satisfied: jupyterlab-pygments==0.1.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 33)) (0.1.2)
Requirement already satisfied: jupyterlab-widgets==1.0.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 34)) (1.0.0)
Requirement already satisfied: MarkupSafe==1.1.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 35)) (1.1.1)
Requirement already satisfied: mistune==0.8.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 36)) (0.8.4)
Requirement already satisfied: nbclient==0.5.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 37)) (0.5.1)
Requirement already satisfied: nbconvert==6.0.7 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 38)) (6.0.7)
Requirement already satisfied: nbformat==5.1.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 39)) (5.1.2)
Requirement already satisfied: nest-asyncio==1.4.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 40)) (1.4.3)
Requirement already satisfied: notebook==6.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 41)) (6.2.0)
Requirement already satisfied: numpy==1.19.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 42)) (1.19.5)
Requirement already satisfied: packaging==20.8 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 43)) (20.8)
Requirement already satisfied: pandas==1.2.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 44)) (1.2.1)
Requirement already satisfied: pandocfilters==1.4.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 45)) (1.4.3)
Requirement already satisfied: parso==0.8.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 46)) (0.8.1)
Requirement already satisfied: pickleshare==0.7.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 47)) (0.7.5)
Requirement already satisfied: Pillow==8.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 48)) (8.1.0)
Requirement already satisfied: prometheus-client==0.9.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 49)) (0.9.0)
Requirement already satisfied: prompt-toolkit==3.0.11 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 50)) (3.0.11)
Requirement already satisfied: protobuf==3.14.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 51)) (3.14.0)
Requirement already satisfied: pyarrow==2.0.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 52)) (2.0.0)
Requirement already satisfied: pycparser==2.20 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 53)) (2.20)
Requirement already satisfied: pydeck==0.5.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 54)) (0.5.0)
Requirement already satisfied: Pygments==2.7.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 55)) (2.7.4)
Requirement already satisfied: pyparsing==2.4.7 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 56)) (2.4.7)
Requirement already satisfied: pyrsistent==0.17.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 57)) (0.17.3)
Requirement already satisfied: python-dateutil==2.8.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 58)) (2.8.1)
Requirement already satisfied: pytz==2020.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 59)) (2020.5)
ERROR: Could not find a version that satisfies the requirement pywin32==300
ERROR: No matching distribution found for pywin32==300
Stopping...
[manager] Error checking Streamlit healthz: Get "http://localhost:8501/healthz": dial tcp 127.0.0.1:8501: connect: connection refused
You can now view your Streamlit app in your browser.
Network URL: http://10.12.4.85:8501
External URL: http://35.230.58.211:8501
这是我的复制品,里面有应用程序:https://github.com/juliangermek/streamit_test
我不明白为什么这在本地有效,但在 Streamlit 共享中却无效。你有什么想法吗?
谢谢,朱利安
部署时应从 requirements.txt
中删除 pywin32==300
等不必要的包。这种类型的包会导致错误,所以最好把不需要的包都去掉。
此外,它不是 sklearn,实际上它是 scikit-learn。所以要安装 scikit-learn
使用这一行:
pip install scikit-learn
见here
您也可以通过打开 requirements.txt 文件手动将 sklearn 的名称更改为 scikit-learn。
scikit-learn==0.22.1
matplotlib==3.2.2
numpy==1.18.1
pandas==1.0.5
streamlit==0.62.0
Werkzeug==1.0.1
我想试用 Streamlit 共享 (https://www.streamlit.io/sharing)。这是我的本地工作代码:
streamlit_app.py
import pandas as pd
import streamlit as st
from PIL import Image
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
# Model
df = pd.read_csv("IRIS.csv")
X = df.drop(columns=["species"])
y = df["species"]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
rf = RandomForestClassifier()
rf.fit(X_train, y_train)
# Streamlit
st.header("Iris Classification")
image = Image.open("iris.jpg")
st.image(image, use_column_width=True, output_format="jpg")
st.write("Please insert values, to get Iris class prediction")
SepalLengthCm = st.slider('SepalLengthCm:', 2.0, 6.0)
SepalWidthCm = st.slider('SepalWidthCm:', 0.0, 5.0)
PetalLengthCm = st.slider('PetalLengthCm',0.0, 3.0)
PetalWidthCm = st.slider('PetalWidthCm:', 0.0, 2.0)
data = {'SepalLengthCm': SepalLengthCm,
'SepalWidthCm': SepalWidthCm,
'PetalLengthCm': PetalLengthCm,
'PetalWidthCm': PetalWidthCm}
features = pd.DataFrame(data, index=[0])
prediction = rf.predict(features)
percentages = rf.predict_proba(features)
st.subheader("Prediction")
st.write(prediction[0])
st.subheader("Percentages")
st.write("Iris-setosa: ", percentages[0][0]*100)
st.write("Iris-versicolor: ", percentages[0][1]*100)
st.write("Iris-virginica: ", percentages[0][2]*100)
现在,为了获得 requirements.txt(流媒体共享所必需的),我执行了以下操作:
- 使用
conda create --name streamlit-test python=3.7
创建新环境
pip install streamlit
pip install sklearn
- 可选:
streamlit run streamlit_app.py
在本地成功运行应用程序 pip freeze > requirements.txt
当我通过 Streamlit 共享部署应用程序时,它显示“ModuleNotFoundError:没有名为 'sklearn' 的模块”(第 5 行)。您实际上应该能够自己看到这个:https://share.streamlit.io/juliangermek/streamit_test
检查 requirements.txt 显示 sklearn 像这样存在 sklearn==0.0
。
这是来自 Streamlit Sharing 的日志:
[client] Connecting...
[manager] Starting up for owner: 'juliangermek', repository: 'streamit_test', branch: 'master', main module: 'streamlit_app.py'
[manager] Cloning repository ...
[manager] Cloning into 'streamit_test'...
[manager] Cloned repository!
[manager] Processing dependencies ...
Requirement already satisfied: altair==4.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (4.1.0)
ERROR: Could not find a version that satisfies the requirement anaconda-client==1.7.2
ERROR: No matching distribution found for anaconda-client==1.7.2
[manager] Processed dependencies!
You can now view your Streamlit app in your browser.
Network URL: http://10.12.4.85:8501
External URL: [2021-01-22 07:46:22.016741] http://35.230.58.211:8501
Requirement already satisfied: altair==4.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (4.1.0)
ERROR: Could not find a version that satisfies the requirement anaconda-client==1.7.2
ERROR: No matching distribution found for anaconda-client==1.7.2
Stopping...
You can now view your Streamlit app in your browser.
Network URL: http://10.12.4.85:8501
External URL: http://35.230.58.211:8501
Requirement already satisfied: altair==4.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (4.1.0)
Requirement already satisfied: argon2-cffi==20.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (20.1.0)
Requirement already satisfied: astor==0.8.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (0.8.1)
Requirement already satisfied: async-generator==1.10 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (1.10)
Requirement already satisfied: attrs==20.3.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (20.3.0)
Requirement already satisfied: backcall==0.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (0.2.0)
Requirement already satisfied: base58==2.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 7)) (2.1.0)
Requirement already satisfied: bleach==3.2.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (3.2.2)
Requirement already satisfied: blinker==1.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 9)) (1.4)
Requirement already satisfied: cachetools==4.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 10)) (4.2.0)
Requirement already satisfied: certifi==2020.12.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 11)) (2020.12.5)
Requirement already satisfied: cffi==1.14.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 12)) (1.14.4)
Requirement already satisfied: chardet==4.0.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 13)) (4.0.0)
Requirement already satisfied: click==7.1.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 14)) (7.1.2)
Requirement already satisfied: decorator==4.4.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 16)) (4.4.2)
Requirement already satisfied: defusedxml==0.6.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 17)) (0.6.0)
Requirement already satisfied: entrypoints==0.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 18)) (0.3)
Requirement already satisfied: gitdb==4.0.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 19)) (4.0.5)
Requirement already satisfied: GitPython==3.1.12 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 20)) (3.1.12)
Requirement already satisfied: idna==2.10 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 21)) (2.10)
Requirement already satisfied: importlib-metadata==3.4.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 22)) (3.4.0)
Requirement already satisfied: ipykernel==5.4.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 23)) (5.4.3)
Requirement already satisfied: ipython==7.19.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 24)) (7.19.0)
Requirement already satisfied: ipython-genutils==0.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 25)) (0.2.0)
Requirement already satisfied: ipywidgets==7.6.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 26)) (7.6.3)
Requirement already satisfied: jedi==0.18.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 27)) (0.18.0)
Requirement already satisfied: Jinja2==2.11.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 28)) (2.11.2)
Requirement already satisfied: jsonschema==3.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 30)) (3.2.0)
Requirement already satisfied: jupyter-client==6.1.11 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 31)) (6.1.11)
Requirement already satisfied: jupyter-core==4.7.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 32)) (4.7.0)
Requirement already satisfied: jupyterlab-pygments==0.1.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 33)) (0.1.2)
Requirement already satisfied: jupyterlab-widgets==1.0.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 34)) (1.0.0)
Requirement already satisfied: MarkupSafe==1.1.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 35)) (1.1.1)
Requirement already satisfied: mistune==0.8.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 36)) (0.8.4)
Requirement already satisfied: nbclient==0.5.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 37)) (0.5.1)
Requirement already satisfied: nbconvert==6.0.7 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 38)) (6.0.7)
Requirement already satisfied: nbformat==5.1.2 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 39)) (5.1.2)
Requirement already satisfied: nest-asyncio==1.4.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 40)) (1.4.3)
Requirement already satisfied: notebook==6.2.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 41)) (6.2.0)
Requirement already satisfied: numpy==1.19.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 42)) (1.19.5)
Requirement already satisfied: packaging==20.8 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 43)) (20.8)
Requirement already satisfied: pandas==1.2.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 44)) (1.2.1)
Requirement already satisfied: pandocfilters==1.4.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 45)) (1.4.3)
Requirement already satisfied: parso==0.8.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 46)) (0.8.1)
Requirement already satisfied: pickleshare==0.7.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 47)) (0.7.5)
Requirement already satisfied: Pillow==8.1.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 48)) (8.1.0)
Requirement already satisfied: prometheus-client==0.9.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 49)) (0.9.0)
Requirement already satisfied: prompt-toolkit==3.0.11 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 50)) (3.0.11)
Requirement already satisfied: protobuf==3.14.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 51)) (3.14.0)
Requirement already satisfied: pyarrow==2.0.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 52)) (2.0.0)
Requirement already satisfied: pycparser==2.20 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 53)) (2.20)
Requirement already satisfied: pydeck==0.5.0 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 54)) (0.5.0)
Requirement already satisfied: Pygments==2.7.4 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 55)) (2.7.4)
Requirement already satisfied: pyparsing==2.4.7 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 56)) (2.4.7)
Requirement already satisfied: pyrsistent==0.17.3 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 57)) (0.17.3)
Requirement already satisfied: python-dateutil==2.8.1 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 58)) (2.8.1)
Requirement already satisfied: pytz==2020.5 in /usr/local/lib/python3.7/site-packages (from -r requirements.txt (line 59)) (2020.5)
ERROR: Could not find a version that satisfies the requirement pywin32==300
ERROR: No matching distribution found for pywin32==300
Stopping...
[manager] Error checking Streamlit healthz: Get "http://localhost:8501/healthz": dial tcp 127.0.0.1:8501: connect: connection refused
You can now view your Streamlit app in your browser.
Network URL: http://10.12.4.85:8501
External URL: http://35.230.58.211:8501
这是我的复制品,里面有应用程序:https://github.com/juliangermek/streamit_test
我不明白为什么这在本地有效,但在 Streamlit 共享中却无效。你有什么想法吗?
谢谢,朱利安
部署时应从 requirements.txt
中删除 pywin32==300
等不必要的包。这种类型的包会导致错误,所以最好把不需要的包都去掉。
此外,它不是 sklearn,实际上它是 scikit-learn。所以要安装 scikit-learn
使用这一行:
pip install scikit-learn
见here
您也可以通过打开 requirements.txt 文件手动将 sklearn 的名称更改为 scikit-learn。
scikit-learn==0.22.1
matplotlib==3.2.2
numpy==1.18.1
pandas==1.0.5
streamlit==0.62.0
Werkzeug==1.0.1