I'm trying to upload my Dash app to Heroku. I've been following the documentation, however, when I go to push I get the following error:
ERROR: Could not find a version that satisfies the requirement numpy==1.20.1
remote: ERROR: No matching distribution found for numpy==1.20.1 (from -r / t tmp/build_32b7cf97/requirements.txt (line 19))
remote: ! Push rejected, failed to compile Python app.
My version of Python is 3.8 and pip is 21.0.1. Oddly enough, I saw this in the output log as well:
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Python app detected
remote: -----> Installing python-3.6.12
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
Heroku installed python 3.6 and pip 20.1.1. Could that be related to the problem? I've looked for similar problems by other users and they recommended deleting the offending dependency from the requirements.txt. But in this case, I need it for my program.
Any suggestions would be greatly appreciated as I have hit a wall.
Starting with the NumPy installation error:
remote: ERROR: Could not find a version that satisfies the requirement numpy==1.20.1 remote: ERROR: No matching distribution found for numpy==1.20.1 (from -r /tmp/build_32b7cf97/requirements.txt (line 19)) remote: ! Push rejected, failed to compile Python app.
That usually means that the NumPy version does not exist or the Python version you are using is not supported by that NumPy version. Checking NumPy's PyPi releases page, 1.20.1 is indeed a valid version. However, checking the NumPy 1.20.0 release notes has this info,
The Python versions supported for this release are 3.7-3.9, support for Python 3.6 has been dropped.
So your guess was correct that it's related to the Python version.
My version of python is 3.8 and pip is 21.0.1
...
Heroku installed python 3.6 and pip 20.1.1
Heroku has its own Python runtime environment and it does not know or care about the Python version you are using on your local env. It will use the default Python version for the chosen stack ("Heroku-20" in your case), and if you want it to use a specific Python version, you have to explicitly tell it which version to use.
From its list of supported runtimes:
By default, newly created Python apps use the python-3.6.13 runtime. You can also specify a different supported Python version.
Supported runtimes
python-3.9.2
on all supported stackspython-3.8.8
on all supported stackspython-3.7.10
on all supported stackspython-3.6.13
on all supported stackspython-2.7.18
on Heroku-16 and Heroku-18 only
If you didn't tell it to use Python 3.8, then it will use the default version of your Heroku stack, which is currently Python 3.6.x. As mentioned above, 3.6 isn't compatible with NumPy 1.20.1.
The fix is simple: specify the runtime:
To specify a Python runtime, add a
runtime.txt
file to your app’s root directory that declares the exact version number to use:$ cat runtime.txt python-3.9.0
So, you need to add a runtime.txt
file, and put in a version that is on the list of supported runtimes (see link above) and is supported by your version of numpy:
python-3.8.8
Lastly, it's good practice to keep your local env's Python version consistent with your deployment env's Python version. Basically, make sure to update your 3.8.2 to match what you specified on runtime.txt for Heroku's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With