TensorFlow installation error

Introduction

During one of my projects, I ran across an issue installing the TensorFlow package. I tried my hardest but was unsuccessful at the beginning.

What is TensorFlow?

Google TensorFlow is an end-to-end platform that makes it easy for you to build and deploy ML models. It has a particular focus on training and inference of deep neural networks. [1]

One of the most famous applications that use TensorFlow is Google RankBrain. Which is a machine learning algorithm that Google uses to sort the search results[2]. Another application for it is Optical Character Recognition (OCR), which is used in converting handwritten text into a digital format. And much more...

In my case, I used it to recognize the sign language using the feedback from the camera.

The installation error

I tried to install it 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.

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

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

I checked my python version, and it was 3.10.4, which is between 3.7 and 3.11 according to my knowledge!!

Solution

The solution was weird at the same level ! Simply I did the following:

  • Open (pyproject.toml for poetry) or (requirements.txt for pip)
  • Change manually the version of Python to be python = ">=3.10,<3.11"
  • If the used OS is Ubuntu then you are good. But if you use Windows the solution continues to be: Enabling the win32 long path by doing this: -Open Local Group Policy Editor. You can search for (gpedit.msc) using windows search from the start menu.
    • Navigate to: Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.
    • Double click Enable NTFS long paths.
    • Select Enabled.
    • Click OK.