0

I am getting an error when I am trying to deploy a Dash app to Heroku.

This is my first time using Heroku and Dash and Plotly. I am trying to deploy this app for my team. I have not saved the code on GitHub. The error I am getting is "failed to push some refs to..."

The complete issue is shown below.

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'
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Saloni Shah
  • 23
  • 1
  • 9
  • 1
    Have you checked the error message? "*xlwings requires an installation of Excel and therefore only works on Windows and macOS*" Your app seems to depend on xlwings but Heroku is running on Linux. You will have to find an alternate library usable on Heroku's environment. – Gino Mempin Jan 16 '21 at 01:13
  • Does this answer your question? [Why did push of a Flask app to Heroku failed?](https://stackoverflow.com/questions/64914456/why-did-push-of-a-flask-app-to-heroku-failed) – Gino Mempin Jan 16 '21 at 01:14
  • @GinoMempin I tried using heroku config:set INSTALL_ON_LINUX=1 on terminal and I got the following message "Setting INSTALL_ON_LINUX and restarting ⬢ dash... done, v3 INSTALL_ON_LINUX: 1" which I am assuming that it worked. After that I tried deploying again but I got the same error. – Saloni Shah Jan 16 '21 at 01:22

1 Answers1

3

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

Heroku does not run Windows or macOS (it runs Linux) and therefore you cannot use xlwings on Heroku.

Setting INSTALL_ON_LINUX=1 bypasses this check and lets installation proceed, but it doesn't change the fact that Heroku is running Linux, not Windows or macOS, and it certainly doesn't provide Excel.

Maybe you're confused about how xlwings works? You might be running Windows or macOS locally, and you might well have Excel available. But the code you deploy to Heroku runs there, and has no way to access Excel on your machine.

You might want to read through What is the difference between client-side and server-side programming? The code you deploy to Heroku runs server-side.

I have no idea what you're trying to do with Excel, but there are other Excel libraries available for Python. Something like openpyxl might be able to take the place of xlwings in your application. It should run on Heroku.

But it might not do what you want—xlwings can do some neat stuff that openpyxl can't.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • Hi Chris, Thank you so much for explaining this. You are absolutely right I am running macOS locally. I am trying to get the dashboard up for my team so that they can look at clean data all at one place. I am new to Python and technology world. I will research on openpyxl and see if I can have my excel data there. Is there any other way in which I can deploy the app using the excel locally to share with the team? – Saloni Shah Jan 16 '21 at 02:31
  • If they're Python-literate you could simply share the source code. If not, you could try [building a macOS app](https://py2app.readthedocs.io/en/latest/). This _might_ work as a hosted application, but I really don't know based on what you've already shared. – ChrisGPT was on strike Jan 16 '21 at 02:51
  • Will it work if I covert .xslx files to .csv ? – Saloni Shah Jan 16 '21 at 20:14
  • @SaloniShah, again, I have _no idea_ what you're using `xlwings` for. You might be able to rewrite your application to use another library like `openpyxl` or to use CSVs instead of XLSX files, but it really depends on what your application _does_. Your question is about why your application doesn't work on Heroku, and I believe I've answered that. If you want to rewrite your appliction, that's a different issue. Give it a try, and if you have another on-topic question, feel free to ask it as a new post. – ChrisGPT was on strike Jan 16 '21 at 20:19