Search code examples
pythontensorflowpippython-poetry

TensorFlow 2.8.0 installing error using pip and poetry with python 3.10.4


Edit 2: Solved

I tried to install TensorFlow many times in different ways:

  • Tried installing it in Windows(10 and 11), WSL2.0 , and Ubuntu OS.
  • Tried installing it on 4 different computers, one of them has i7-11800H, RTX3060, and 16GB RAM.
  • Tried installing it using pip and poetry.
  • Tried installing it using CML (Powershell and Ubuntu) and PyCharm package manager.
  • Tried venv and poetry shell for the environment.

The following result appeared every time (for example, after entering poetry add tensorflow or pip install tensorflow)

Updating dependencies
Resolving dependencies...

  SolverProblemError

  The current project's Python requirement (>=3.10,<4.0) is not compatible with some of the required packages Python requirement:
    - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
    - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
    - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0

  Because no versions of tensorflow-io-gcs-filesystem match >0.23.1,<0.24.0 || >0.24.0,<0.25.0 || >0.25.0
   and tensorflow-io-gcs-filesystem (0.23.1) requires Python >=3.7, <3.11, tensorflow-io-gcs-filesystem is forbidden.
  And because tensorflow-io-gcs-filesystem (0.24.0) requires Python >=3.7, <3.11
   and tensorflow-io-gcs-filesystem (0.25.0) requires Python >=3.7, <3.11, tensorflow-io-gcs-filesystem is forbidden.
  Because no versions of tensorflow match >2.8.0,<3.0.0
   and tensorflow (2.8.0) depends on tensorflow-io-gcs-filesystem (>=0.23.1), tensorflow (>=2.8.0,<3.0.0) requires tensorflow-io-gcs-filesystem (>=0.23.1).
  Thus, tensorflow is forbidden.
  So, because pythonproject4 depends on tensorflow (^2.8.0), version solving failed.

  at ~\AppData\Roaming\Python\Python310\site-packages\poetry\puzzle\solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.10,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.10,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.10,<3.11"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

There is no problem with installing TF 2.8 on Python 3.9 But my question is: since I have Python 3.10.4 why the following error happens

tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0


Edit:

When I manually edited the dependencies in .toml file to be like this:

[tool.poetry.dependencies]

python = ">=3.10,<3.11"

it installed most of the package then it failed in something and the following error appeared:

Using version ^2.8.0 for tensorflow

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 34 installs, 0 updates, 0 removals

  • Installing certifi (2021.10.8)
  • Installing charset-normalizer (2.0.12)
  • Installing idna (3.3)
  • Installing pyasn1 (0.4.8)
  • Installing urllib3 (1.26.9)
  • Installing cachetools (5.0.0)
  • Installing oauthlib (3.2.0)
  • Installing pyasn1-modules (0.2.8)
  • Installing requests (2.27.1)
  • Installing rsa (4.8)
  • Installing google-auth (2.6.6)
  • Installing requests-oauthlib (1.3.1)
  • Installing google-auth-oauthlib (0.4.6)
  • Installing grpcio (1.46.0)
  • Installing markdown (3.3.7)
  • Installing tensorboard-data-server (0.6.1)
  • Installing tensorboard-plugin-wit (1.8.1)
  • Installing werkzeug (2.1.2)
  • Installing astunparse (1.6.3)
  • Installing flatbuffers (2.0)
  • Installing gast (0.5.3)
  • Installing google-pasta (0.2.0)
  • Installing h5py (3.6.0)
  • Installing keras (2.8.0)
  • Installing keras-preprocessing (1.1.2)
  • Installing libclang (14.0.1)
  • Installing opt-einsum (3.3.0)
  • Installing tensorboard (2.8.0)
  • Installing tensorflow-io-gcs-filesystem (0.25.0)
  • Installing termcolor (1.1.0)
  • Installing tf-estimator-nightly (2.8.0.dev2021122109)
  • Installing typing-extensions (4.2.0)
  • Installing wrapt (1.14.1)
  • Installing tensorflow (2.8.0)

  EnvCommandError

  Command C:\Users\majda\AppData\Local\pypoetry\Cache\virtualenvs\pythonproject3-pEOchWpC-py3.10\Scripts\pip.exe install --no-deps C:\Users\majda\AppData\Local\pypoetry\Cache\artifacts\9b\54\38\c69dfa96cba7e69e543db60e6f1bc9060f68c5cf51bdb1796760b5bfcc\tensorflow-2.8.0-cp310-cp310-win_amd64.whl errored with the following return code 1, and output: 
  Processing c:\users\majda\appdata\local\pypoetry\cache\artifacts\9b\54\38\c69dfa96cba7e69e543db60e6f1bc9060f68c5cf51bdb1796760b5bfcc\tensorflow-2.8.0-cp310-cp310-win_amd64.whl
  Installing collected packages: tensorflow
  ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\majda\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\pythonproject3-pEOchWpC-py3.10\\Lib\\site-packages\\tensorflow\\include\\external\\cudnn_frontend_archive\\_virtual_includes\\cudnn_frontend\\third_party\\cudnn_frontend\\include\\cudnn_frontend_EngineConfigGenerator.h'
  HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
  
  

  at ~\AppData\Roaming\Python\Python310\site-packages\poetry\utils\env.py:1195 in _run


Failed to add packages, reverting the pyproject.toml file to its original content.

Edit 2 :

If you use Ubuntu the second error won't happen. But if you use Windows the solution for that error according to microfocus is:

  1. Click Window key and type gpedit.msc, then press the Enter key. This launches the Local Group Policy Editor.

  2. Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.

  3. Double click Enable NTFS long paths.

  4. Select Enabled, then click OK


Solution

  • When using poetry, in your pyproject.toml edit manually:

    [tool.poetry.dependencies]
    python = ">=3.10,<3.11"