无法在 Heroku 上部署 Streamlit 应用程序 - 缺少 libgcc_s.so.1

Posted

技术标签:

【中文标题】无法在 Heroku 上部署 Streamlit 应用程序 - 缺少 libgcc_s.so.1【英文标题】:Unable to Deploy Streamlit app on Heroku - missing libgcc_s.so.1 【发布时间】:2020-11-10 20:58:27 【问题描述】:

概述: 我正在尝试部署一个使用 OpenCV 和 Tensorflow 对人的面部表情进行分类的 Web 应用程序。因此,一个人上传了一张图片,应用程序会在面部周围生成一个带有该人表情的边界框。当我在本地机器上运行 Streamlit 应用程序时,它与相同的 requirements.txt 完美配合。但是,该应用在 Heroku 上不断崩溃。

这是日志的输出:

2020-07-21T12:56:02.435384+00:00 heroku[web.1]: Starting process with command `sh setup.sh && streamlit run app.py`
2020-07-21T12:56:05.484243+00:00 app[web.1]: 
2020-07-21T12:56:05.484269+00:00 app[web.1]: Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
2020-07-21T12:56:05.484271+00:00 app[web.1]: As a result, 'server.enableCORS' is being overridden to 'true'.
2020-07-21T12:56:05.484271+00:00 app[web.1]: 
2020-07-21T12:56:05.484272+00:00 app[web.1]: More information:
2020-07-21T12:56:05.484272+00:00 app[web.1]: In order to protect against CSRF attacks, we send a cookie with each request.
2020-07-21T12:56:05.484273+00:00 app[web.1]: To do so, we must specify allowable origins, which places a restriction on
2020-07-21T12:56:05.484273+00:00 app[web.1]: cross-origin resource sharing.
2020-07-21T12:56:05.484273+00:00 app[web.1]: 
2020-07-21T12:56:05.484274+00:00 app[web.1]: If cross origin resource sharing is required, please disable server.enableXsrfProtection.
2020-07-21T12:56:05.484279+00:00 app[web.1]:             
2020-07-21T12:56:08.293129+00:00 app[web.1]: 
2020-07-21T12:56:08.293160+00:00 app[web.1]: Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
2020-07-21T12:56:08.293161+00:00 app[web.1]: As a result, 'server.enableCORS' is being overridden to 'true'.
2020-07-21T12:56:08.293161+00:00 app[web.1]: 
2020-07-21T12:56:08.293163+00:00 app[web.1]: More information:
2020-07-21T12:56:08.293164+00:00 app[web.1]: In order to protect against CSRF attacks, we send a cookie with each request.
2020-07-21T12:56:08.293164+00:00 app[web.1]: To do so, we must specify allowable origins, which places a restriction on
2020-07-21T12:56:08.293164+00:00 app[web.1]: cross-origin resource sharing.
2020-07-21T12:56:08.293165+00:00 app[web.1]: 
2020-07-21T12:56:08.293165+00:00 app[web.1]: If cross origin resource sharing is required, please disable server.enableXsrfProtection.
2020-07-21T12:56:08.293166+00:00 app[web.1]:             
2020-07-21T12:56:08.485342+00:00 app[web.1]: libgcc_s.so.1 must be installed for pthread_cancel to work
2020-07-21T12:56:08.537947+00:00 heroku[web.1]: Process exited with status 134
2020-07-21T12:58:42.417606+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fer-2013.herokuapp.com request_id=ad34f9af-1463-49a4-b60d-21e642a793cd fwd="122.175.13.11" dyno= connect= service= status=503 bytes= protocol=https
2020-07-21T12:58:44.741839+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fer-2013.herokuapp.com request_id=e483f00f-01e1-46f7-bc66-e8f1020c3638 fwd="122.175.13.11" dyno= connect= service= status=503 bytes= protocol=https

这是我的 Procfile 的输出:

web: sh setup.sh && streamlit run app.py

这是我的 setup.sh 的输出:

mkdir -p ~/.streamlit/

echo "\
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml

这里是 GitHub 存储库的链接: https://github.com/Manas73/fer-2013

【问题讨论】:

创建一个Aptfile,内容为libgcc1。将apt buildpack 添加到您的项目中。 没有帮助。我仍然遇到同样的错误。 【参考方案1】:

原来我的 requirements.txt 中有 opencv-python,我只是用 opencv-contrib-python-headless 替换了它。现在可以完美运行了。

【讨论】:

以上是关于无法在 Heroku 上部署 Streamlit 应用程序 - 缺少 libgcc_s.so.1的主要内容,如果未能解决你的问题,请参考以下文章

部署streamlit工程到Heroku

部署streamlit工程到Heroku

Streamlit Python 应用程序成功部署到 Heroku,但出现应用程序错误

统计 Heroku-Streamlit Web 应用的请求数

ModuleNotFoundError:将 Streamlit 应用程序部署到 Heroku 时没有名为“google.cloud”的模块

Heroku - 进程以状态 255 退出