python - 部署 Dash 应用程序时出现 Heroku 应用程序错误:“OSError:xlwings 需要安装 Excel,因此仅适用于 Windows 和 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 需要安装 Excel,因此仅适用于 Windows 和 macOS
Heroku 不运行 Windows 或 macOS(它运行 Linux),因此您不能xlwings
在 Heroku 上使用。
设置INSTALL_ON_LINUX=1
会绕过此检查并让安装继续进行,但它不会改变 Heroku 运行的是 Linux,而不是 Windows 或 macOS 的事实,而且它当然不提供 Excel。
也许你对如何xlwings
工作感到困惑?您可能在本地运行 Windows 或 macOS,并且您可能有 Excel 可用。但是您部署到 Heroku 的代码在那里运行,并且无法访问您机器上的 Excel。
您可能想通读一下客户端和服务器端编程之间的区别是什么?您部署到 Heroku 的代码运行server-side。
我不知道你想用 Excel 做什么,但还有其他可用于 Python 的 Excel 库。类似的东西openpyxl
可能会xlwings
在您的应用程序中取代。它应该在 Heroku 上运行。
但它可能不会做你想做的事——<code>xlwings 可以做一些不能做的整洁的事情openpyxl
。
推荐阅读
- android - USB 麦克风和设备的扬声器可以同时工作吗?
- java - 使用 openjdk 13.0.2 运行时,运行 .jar 文件会引发异常
- javascript - AngularJS ($http GET): $scope.names 始终是一个空数组,但调用后端是可以的
- oauth-2.0 - 如何使用 Azure Functions 强制执行 AAD 应用程序角色授权?
- react-native - 使用 Jest 和酶测试 React Native 中的按钮单击
- mysql - 在 pythonanywhere 中将 sql 文件导入 MySQL
- javascript - 如何使用jquery获取数组值
- android - 在返回意图 ACTION_PICK 之前预览图像
- r - 如何使用 R 绘制基于分类/离散因子的分类变量的 PCA 替代方案?
- ios - 如何给精灵精确的触摸位置?