0

I am trying to install tensorflow federated using command: pip install tensorflow_federated The installation completes successfuly, but when I am import the package using command import tensorflow_federated as tff I get below error:

Traceback (most recent call last): File "", line 1, in File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/init.py", line 25, in from tensorflow_federated.python import * File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/python/init.py", line 25, in from tensorflow_federated.python.core import * File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/python/core/init.py", line 21, in from tensorflow_federated.python.core import utils File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/python/core/utils/init.py", line 26, in from tensorflow_federated.python.core.utils.computation_utils import IterativeProcess File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/python/core/utils/computation_utils.py", line 21, in from tensorflow_federated.python.core import api as tff File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/python/core/api/init.py", line 22, in from tensorflow_federated.python.core.api.computation_types import FederatedType File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/python/core/api/computation_types.py", line 26, in from tensorflow_federated.python.common_libs import anonymous_tuple File "/home/dgholam/.local/lib/python3.10/site-packages/tensorflow_federated/python/common_libs/anonymous_tuple.py", line 28, in nest = tf.contrib.framework.nest AttributeError: module 'tensorflow' has no attribute 'contrib'

I will appreciate to you, if you can help me with this issue. Python: 3.10.2 tensorflow-federated 0.1.0 tensorflow 2.11.0

I tried to install it with python 3.9.2 and 3.9.7 but I got another errors during installation. It seems tensorflow-federated needs tensorflow 2 and in tensorflow 2 there no contrib anymore. (contrib belongs to tensforlow 1.x.x)

2 Answers 2

1

You are trying to install the oldest version of TensorFlow Federated (TF Federated 0.1.0, released on Feb 23, 2019)in the latest release of Python version 3.10 or 3.9 which is causing the above error.

Please use the below command to upgrade the TensorFlow Federated version :

!pip install --quiet --upgrade tensorflow-federated

and then import TensorFlow Federated as below:

import tensorflow_federated as tff
print(tff.federated_computation(lambda: 'Hello, World!')())
print(tff.__version__)

Output:

b'Hello, World!'
0.56.0
Sign up to request clarification or add additional context in comments.

2 Comments

Hi @Davoud Gholamian, Could you please accept the answer if it worked for you? Thank you.
This doesn't work on my machine, which refuses to upgrade to version 0.56 or higehr
1

!pip install --quiet --upgrade tensorflow-federated

This cmd doesn't upgrage tensorflow-federated to 0.56, it is still 0.1.0

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.