'Cant to install tensorflow_federated

I try to install tensorflow federated.

pip install --quiet --upgrade tensorflow_federated_nightly

but when I want to import tensorflow federated, I get this warning and after that google colab notebook is restarted.

WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.base has been moved to tensorflow.python.trackable.base. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.checkpoint_management has been moved to tensorflow.python.checkpoint.checkpoint_management. The old module will be deleted in version 2.9.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.resource has been moved to tensorflow.python.trackable.resource. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.util has been moved to tensorflow.python.checkpoint.checkpoint. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.base_delegate has been moved to tensorflow.python.trackable.base_delegate. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.tracking.graph_view has been moved to tensorflow.python.checkpoint.graph_view. The old module will be deleted in version 2.11.

Also, I try install tensorflow federated as this way:

pip install --quiet --upgrade tensorflow_federated

but get error when import tensorflow federated

TypeError: 'type' object is not subscriptable

how do I fix it?



Solution 1:[1]

It's a compatibility issue , I faced this same error message while working with Google Colab, just installed tensorflow-federated==0.20.0 as a quick fix as described in this issue on github: https://github.com/tensorflow/federated/issues/2748#issuecomment-1107437271

Solution 2:[2]

You can set default values in function params - e.g.:

def url(host, port=5432):

Solution 3:[3]

I don't get that error when I run your code, I get IndexError: list index out of range when trying to reference sys.argv[2]

This is a possible solution:

import sys
def url(host, port=5432):
    gen_url = f'http://{host}:{port}/'
    print(gen_url)

url(*sys.argv[1:3])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user8421958
Solution 2 match
Solution 3 Chris J