You are not logged in.

#1 2023-11-27 10:23:28

jbell
Member
Registered: 2020-05-13
Posts: 11

[Solved] Tensorflow requires python 3.10 but 3.11 is installed

Hi, I try to use tensorflow but when I import the module I get this error message. I seems like tensorflow requires python3.10 but the default of arch is python3.11.
This is strange because tensorflow officially supports python3.11 (see here: https://www.tensorflow.org/install) and I have the latest version 2.15. installed.

I also tried to make sure that I have no pip version of tensorflow installed. I removed TF using pacman -Rsu python-tensorflow and when I tried to import it using python, I got a "module not found" error.
So now I reinstalled it but I still have the following error:

$ python -c "import tensorflow"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.11/site-packages/tensorflow/__init__.py", line 45, in <module>
    from tensorflow.python import tf2 as _tf2
  File "/usr/lib/python3.11/site-packages/tensorflow/python/tf2.py", line 21, in <module>
    from tensorflow.python.platform import _pywrap_tf2
ImportError: Python version mismatch: module was compiled for Python 3.10, but the interpreter version is incompatible: 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801].
$ pacman -Qi tensorflow
Name                     : tensorflow
Version                  : 2.15.0-1
$ pacman -Qi python-tensorflow
Name                     : python-tensorflow
Version                  : 2.15.0-1
$ python --version
Python 3.11.6

Last edited by jbell (2023-12-01 10:07:25)

Offline

#2 2023-11-27 10:43:05

FuzzySPb
Member
Registered: 2013-01-21
Posts: 68

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

HI jbell,

I confirm that I got the same problem recently. For me it looks like Arch-repo versions misalignment. But let's see what others will say.
I think problem came to me with tensorflow-opt-cuda-2.15.0-1-x86_64 package that I installed yesterday.

Last edited by FuzzySPb (2023-11-27 10:45:40)

Offline

#3 2023-11-27 12:55:06

loqs
Member
Registered: 2014-03-06
Posts: 18,859

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

Please open a bug report on Arch's gitlab instance https://gitlab.archlinux.org/archlinux.

Offline

#4 2023-11-27 13:21:28

FuzzySPb
Member
Registered: 2013-01-21
Posts: 68

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

loqs wrote:

Please open a bug report on Arch's gitlab instance https://gitlab.archlinux.org/archlinux.

Hi, thanks for your guidance. But I'm a bit confused as previously I reported package related problems via https://bugs.archlinux.org/
How to choose a right place to report this thing? (i.e. gitlab.archlinux.org or bugs.archlinux.org?)

Last edited by FuzzySPb (2023-11-27 13:21:57)

Offline

#5 2023-11-27 13:27:46

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,889

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

All bugs have been migrated to gitlab and bugs.archlinux.org has been set to readonly.
Just use the "Add a new Bug" button on the pacakge page and it will take you to the gitlab instance.


see https://lists.archlinux.org/hyperkitty/ … H67IDVGTS/ for more info


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#6 2023-11-27 13:36:47

loqs
Member
Registered: 2014-03-06
Posts: 18,859

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

I think the fix may be as simple as:

diff --git a/PKGBUILD b/PKGBUILD
index 6e1cf94..268bece 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -114,6 +114,7 @@ prepare() {
   # add latest PTX for future compatibility
   # Valid values can be discovered from nvcc --help
   export TF_CUDA_COMPUTE_CAPABILITIES=sm_52,sm_53,sm_60,sm_61,sm_62,sm_70,sm_72,sm_75,sm_80,sm_86,sm_87,sm_89,sm_90,compute_90
+  export TF_PYTHON_VERSION=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
 
   export BAZEL_ARGS="--config=mkl -c opt"
 }

However building tensorflow with that change will take me a few hours before I can test it.
Edit:
https://gitlab.archlinux.org/archlinux/ … -/issues/4

Last edited by loqs (2023-11-27 14:10:18)

Offline

#7 2023-11-29 19:10:06

jbell
Member
Registered: 2020-05-13
Posts: 11

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

Hey, I saw that the gitlab issue is closed, so I tested again but I still get the same error, even though I have the new version 2.15.0-2 installed.
I already tried reinstalling python-tensorflow and tensorflow but this did not fix it.
Should this issue be fixed now or are there still some open issues?

$ pacman -Qi tensorflow 
Name                     : tensorflow
Version                  : 2.15.0-2

Last edited by jbell (2023-11-29 19:10:35)

Offline

#8 2023-11-29 19:23:56

loqs
Member
Registered: 2014-03-06
Posts: 18,859

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

There has been no new package release since [1][2] were committed.
[1]: https://gitlab.archlinux.org/archlinux/ … 46c83ff8df
[2]: https://gitlab.archlinux.org/archlinux/ … 67b7ee0703
Edit:
I built the package with those two commits applied and an unrelated change (use gcc 13 instead of gcc 12).  The folder linked below contains all the tensorflow packages apart from the debug package.  You will also need python-ml-dtypes which is a new dependency of python- the python tensorflow packages.

https://drive.google.com/drive/folders/ … drive_link

Last edited by loqs (2023-11-30 00:05:26)

Offline

#9 2023-11-30 16:39:52

FuzzySPb
Member
Registered: 2013-01-21
Posts: 68

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

I've just upgraded to 2.15.0-3 - it appears solving the problem.

But then I got another one:

YYYY-MM-DD HH:MM:SS: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Segmentation fault (core dumped)

I'm not sure is Segmentation fault connected with a message above but I didn't have it with vertion 2.13.

Last edited by FuzzySPb (2023-12-01 09:38:37)

Offline

#10 2023-12-01 10:07:07

jbell
Member
Registered: 2020-05-13
Posts: 11

Re: [Solved] Tensorflow requires python 3.10 but 3.11 is installed

Hey, it works now. I also get a warning but in the end the version is printed. Also, I was able to train a model.
Thank you really much for your efforts!

$ python -c 'import tensorflow as tf; print(tf.__version__)'
2023-12-01 10:58:23.116892: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2.15.0
$ pacman -Qi python-tensorflow
Name                     : python-tensorflow
Version                  : 2.15.0-3

Offline

Board footer

Powered by FluxBB