3

I am trying to deploy a Flask app to Heroku. In order for the app to be able to use Keras properly, Tensorflow has to be atleast version 2.2. So I did pipenv install tensorflow (like I did for all of my dependencies), which put tensorflow version 2.3 in my Pipfile.lock file and tensorflow = "*" in my Pipfile. I also put tensorflow==2.3 as a requirement in my requirements.txt file. However, when I try to push these changes to Heroku, Heroku responds with the following error:

Could not find a version that satisfies the requirement tensorflow==2.3.0 (from -r /tmp/pipenv-imj6590f-requirements/pipenv-fawijosx-requirement.txt (line 1)) (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1)
remote:        No matching distribution found for tensorflow==2.3.0 (from -r /tmp/pipenv-imj6590f-requirements/pipenv-fawijosx-requirement.txt (line 1))
remote:        You are using pip version 9.0.2, however version 20.2.2 is available.
remote:        You should consider upgrading via the 'pip install --upgrade pip' command.

This is troubling because like I said earlier, I need Heroku to have a tensorflow version that is atleast 2.2. I think it might be because the pip version that Heroku is using is 9.0.2, and in order to use Tensorflow 2, you must have atleast pip version 19. How do I get the tensorflow 2.3 requirement to be satisfied by Heroku? I have been trying to solve this issue for hours with no luck, so any help would be much appreciated. Thanks!

watersheep23
  • 339
  • 1
  • 3
  • 17
  • 2
    TensorFlow 2 require a pip version above 19.0 You are using `pip version 9.0.2` you have to run `pip install --upgrade pip` Check: [Install TensorFlow with pip](https://www.tensorflow.org/install/pip) – Mohnish Aug 30 '20 at 03:07
  • Ok I'm trying that, put doesn't that just update my local pip version and not Heroku's? – watersheep23 Aug 30 '20 at 03:26
  • Yeah that didn't work, that only updates my local pip I think...after I did pip install --upgrade pip, I did pushed to heroku and got the same error as described in the question. Any other ideas? – watersheep23 Aug 30 '20 at 03:37
  • And I'm using pip version 20.2.2 (I just checked with pip -V), not 9.0.2, I think Heroku is the one using 9.0.2 – watersheep23 Aug 30 '20 at 03:38
  • Actually I think you're right...lol I'm just now reading the error again and heroku does say that I am the one who has the old pip version, but when I do pip -V, it says that I have version 20.0.2....how else am I supposed to upgrade my pip version? – watersheep23 Aug 30 '20 at 04:33
  • you can add your requirements like `tensorflow==2.2` in `requirements.txt` as per [Heroku's changelogs](https://devcenter.heroku.com/changelog-items/1740) It will use pip 20.0.2 – Mohnish Aug 30 '20 at 06:00
  • I already have that in my requirements.txt – watersheep23 Aug 30 '20 at 06:10
  • The main issue I think is that heroku says I have pip version 9.0.2, but when I do pip -V, it says I have pip version 20.2.2....why is heroku saying that I have 9.0.2 when pip -V says I have 20.2.2? – watersheep23 Aug 30 '20 at 06:57
  • you have to run `pip` on server - if only Heroku let you do it. Did you use Google to check how to upgrade `pip` on Heroku? You may try to use `pip==20.0.2` in `requirements.txt`. Using Google I found [Pip updated to 20.0.2](https://devcenter.heroku.com/changelog-items/1740). You should ask Heroku's admins for this problem – furas Aug 30 '20 at 09:12
  • "I also put tensorflow==2.3 as a requirement in my requirements.txt file"—this shouldn't be causing your problem, but it's entirely unnecessary and likely to lead to confusion. Use _only one_ of Pipenv or pip. If Heroku sees a `Pipfile` and a `Pipfile.lock` it will ignore any `requirements.txt` file. – ChrisGPT was on strike Aug 30 '20 at 12:30
  • Ok so I can just do away with the Pipfile and Pipfile.lock? – watersheep23 Aug 30 '20 at 17:11
  • @furas I already have that in my requirements.txt file – watersheep23 Aug 30 '20 at 17:13
  • as i said before: You should ask Heroku's admins for this problem. They have access to servers and can update `pip` if something wrong. – furas Aug 30 '20 at 17:25
  • I got it to work by removing my Pipfile and Pipfile.lock! Thanks @Chris, that makes a lot of sense, I was wondering if it was a bad idea to have Pipfile, Pipfile.lock, and requirements.txt (since Pipfile/Pipfile.lock and requirements.txt essentially do the same thing), thanks! – watersheep23 Aug 30 '20 at 17:27

2 Answers2

3

Have quite same problem with tensorflow==2.5.0 Get this:

Compiled slug size: 528.8M is too large (max is 500M).
remote:  !     See: http://devcenter.heroku.com/articles/slug-size

my file was too large. According to this I changed tensorflow==2.5.0 to tensorflow-cpu==2.5.0. That way I save ~300MB.
Heroku don't support GPU anyways.

0

@Mohnish,

How to do the below commmand in heroku. (i couldn't find any cmd pannel there)

pip install --upgrade pip

OR

pip version 9.0.2
JOEL
  • 29
  • 7