Heroku application error when deploying Dash app: "OSError: xlwings requires an installation of Excel and therefore only works on Windows and macOS."

Heroku application error when deploying Dash app: "OSError: xlwings requires an installation of Excel and therefore only works on Windows and macOS."

我在尝试将 Dash 应用程序部署到 Heroku 时遇到错误。

这是我第一次使用 Heroku、Dash 和 Plotly。我正在尝试为我的团队部署此应用程序。我没有在 GitHub 上保存代码。我得到的错误是“无法将一些引用推送到...”

完整的问题如下所示。

remote:        Collecting xlwings==0.20.4
remote:          Downloading xlwings-0.20.4.tar.gz (647 kB)
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pamtz4zz/xlwings/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pamtz4zz/xlwings/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-jxny1ijq
remote:                 cwd: /tmp/pip-install-pamtz4zz/xlwings/
remote:            Complete output (5 lines):
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-install-pamtz4zz/xlwings/setup.py", line 32, in <module>
remote:                raise OSError("xlwings requires an installation of Excel and therefore only works on Windows and macOS. To enable the installation on Linux nevertheless, do: export INSTALL_ON_LINUX=1; pip install xlwings")
remote:            OSError: xlwings requires an installation of Excel and therefore only works on Windows and macOS. To enable the installation on Linux nevertheless, do: export INSTALL_ON_LINUX=1; pip install xlwings
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to dash.
remote: 
To https://git.heroku.com/dash.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dash.git'

xlwings requires an installation of Excel and therefore only works on Windows and macOS

Heroku 没有 运行 Windows 或 macOS(它 运行s Linux)因此你不能在 Heroku 上使用 xlwings

设置 INSTALL_ON_LINUX=1 绕过此检查并让安装继续进行,但这不会改变 Heroku 运行ning Linux 而不是 Windows 或 macOS 的事实, 它当然不提供 Excel.

也许您对 xlwings 的工作原理感到困惑?您可能在本地使用 运行ning Windows 或 macOS,并且很可能有 Excel 可用。但是你部署到Heroku 运行s 那里的代码,并没有办法在你的机器上访问Excel。

您可能想通读 What is the difference between client-side and server-side programming? 您部署到 Heroku 运行s 服务器端.

的代码

我不知道你想用 Excel 做什么,但是还有其他 Excel 库可用于 Python。 openpyxl 之类的内容可能会在您的应用程序中取代 xlwings。它应该在 Heroku 上 运行。

但它可能不会做你想做的事情——xlwings 可以做一些 openpyxl 做不到的事情。