poetry: can't install tensorflow==2.0.0rc0 with poetry (python3.6.5)

  • I am on the latest Poetry version.
    • (I’m actually on 1.0.0b1)
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

  1. Open a new project (poetry new .)
  2. run poetry add tensorflow==2.0.0rc0

Fails because it can’t install functools32 (for python2 only). debug logs - https://gist.github.com/zachmoshe/8bd72026dd727380f4b88dc4ef55ff4f

Installing previous versions works and installing rc0 with pip also works. I understand functools32 is a new dependency and that somehow we try to install a version which only work with python2. I just can’t understand why do we try this specific version.

Any solution or a workaround?

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 13
  • Comments: 28 (3 by maintainers)

Commits related to this issue

Most upvoted comments

so Poetry rightly assumes

Uh, if pip installs it fine, but poetry screws up, is it really “rightly”?

Unfortunately, this is not on Poetry’s end. If you take a look at https://pypi.org/pypi/tensorflow/json in the requires_dist section of the info property, functools32 is specified as a dependency without any environment marker so Poetry rightly assumes that it’s an unconditional dependency.

So, this issue must be fixed upstream by the tensorflow maintainers

poetry add tensorflow@^2.1.0rc0

works for me

tensorflow 2.1.0 should be released soon.

Is there a particular workaround at the moment so that TF 2.0 can be installed?

Installing Tensorflow 1.15.2 or 1.15.3 works fine for me.

For anyone having similar issues, I’d recommend trying poetry shell then pip install -U pip to upgrade pip. I was having issues with poetry finding tensorflow@2.1.0, and found that the poetry virtualenv pip was on version 17, even though mine was on 20.

So, this issue must be fixed upstream by the tensorflow maintainers

https://github.com/tensorflow/tensorflow/pull/32758 It may fixes the issue, but need to wait until 2.1 release.

This is also a problem with Tensorflow 1.15, and some python libraries require the 1.x version of Tensorflow.

I also ran into this issue with Tensorflow 1.15.0, but Tensorflow 1.14.0 installs OK.

This is also a problem with Tensorflow 1.15, and some python libraries require the 1.x version of Tensorflow.

This exact problem is related to a Tensorflow release candidate having bad metadata. If you’re having issues installing Tensorflow, I suggest you go to Discussions or Discord to get help, as there are many common misconceptions and pitfalls, and we don’t yet have a FAQ for involved binary packages like Tensorflow and PyTorch.

I found some reasons that functools32 dependency found even if Python3 projects you have:

  1. poetry find a dependencies from PyPI’s “requires_dist”, and tensorflow 2.0.0rc0 or rc1 has functools32 in it:

https://pypi.org/ pypi/tensorflow/2.0.0rc0/json:

"requires_dist": [
      "absl-py (>=0.7.0)",
      "astor (>=0.6.0)",
      "gast (>=0.2.0)",
      "google-pasta (>=0.1.6)",
      "keras-applications (>=1.0.8)",
      "keras-preprocessing (>=1.0.5)",
      "numpy (<2.0,>=1.16.0)",
      "opt-einsum (>=2.3.2)",
      "six (>=1.10.0)",
      "protobuf (>=3.6.1)",
      "tb-nightly (<1.15.0a20190807,>=1.15.0a20190806)",
      "tf-estimator-nightly (<1.14.0.dev2019080602,>=1.14.0.dev2019080601)",
      "termcolor (>=1.1.0)",
      "wrapt (>=1.11.1)",
      "grpcio (>=1.8.6)",
      "wheel",
      "mock (>=2.0.0)",
      "functools32 (>=3.2.3)",
      "backports.weakref (>=1.0rc1); python_version < \"3.4\"",
      "enum34 (>=1.1.6); python_version < \"3.4\""
    ],

ref: https://github.com/sdispater/poetry/blob/cb8dc0d94e68042f120441b4e30d89c92598b40e/poetry/repositories/pypi_repository.py#L286

So at first, we need to modify tensorflow package metadata. I think it’s a tensorflow team matter.

  1. Even if requires_dist is null, poetry tries to get dependencies from universal bdist_wheel. and tensorflow doesn’t have a universal wheel, it chooses a first wheel to inspect (it’s a cp27 wheel).

ref: https://github.com/sdispater/poetry/blob/cb8dc0d94e68042f120441b4e30d89c92598b40e/poetry/repositories/pypi_repository.py#L350

So poetry need to be fixed these logics, IMO, it should respect Python version of venv.