federated icon indicating copy to clipboard operation
federated copied to clipboard

TypeError: 'ABCMeta' object is not subscriptable

Open ns-it opened this issue 2 years ago • 4 comments

I get this error whenever I try to import tendorflow_federated, what could be the reason? I am working on google Colab.

ns-it avatar Apr 22 '22 14:04 ns-it

I get the same error.

I am working on your example notebook within Colab the following command yields the error

import tensorflow_federated as tff


TypeError Traceback (most recent call last) in () 3 import numpy as np 4 import tensorflow as tf ----> 5 import tensorflow_federated as tff 6 import pandas as pd 7 3 frames /usr/local/lib/python3.7/dist-packages/tensorflow_federated/python/program/file_utils.py in () 39 40 ---> 41 def read_saved_model(path: Union[str, os.PathLike[str]]) -> Any: 42 """Reads a SavedModel from path.""" 43 py_typecheck.check_type(path, (str, os.PathLike)) TypeError: 'ABCMeta' object is not subscriptable

Yesterday the same command was working, My first guess was that this is due to changes made in other dependencies. As the update of the package fails aswell:

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

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. spacy 2.2.4 requires tqdm<5.0.0,>=4.38.0, but you have tqdm 4.28.1 which is incompatible. pymc3 3.11.4 requires cachetools>=4.2.1, but you have cachetools 3.1.1 which is incompatible. panel 0.12.1 requires tqdm>=4.48.0, but you have tqdm 4.28.1 which is incompatible. fbprophet 0.7.1 requires tqdm>=4.36.1, but you have tqdm 4.28.1 which is incompatible. datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible. albumentations 0.1.12 requires imgaug<0.2.7,>=0.2.5, but you have imgaug 0.2.9 which is incompatible.

But in the file_utils.py, where the error occurs none of these dependencies is needed.

sprenkamp avatar Apr 22 '22 17:04 sprenkamp

I think it's a compatibility problem with the new release, I installed the previous release tensorflow-federated==0.20.0 and things now seem to be fine, hope they fix this soon.

ns-it avatar Apr 23 '22 09:04 ns-it

Cheers, works well as quick fix.

sprenkamp avatar Apr 23 '22 09:04 sprenkamp

I get a similar error when working with Colab and trying to import tensorflow_federated. The difference is that I was using version 0.22.0 and it now says TypeError: 'type' object is not subscriptable.

The suggestion by @ns-it works for me as well, perfect. Thank you! (just wrote my comment for the developers in hope they will fix it)

thezizzler avatar Apr 27 '22 19:04 thezizzler

The root issue is that Google Colab is on python 3.8 and tensorflow-federated is using python 3.9 API. Installing an older version of tensorflow-federated or using a custom runtime in Google Colab could solve this issue.

michaelreneer avatar Aug 19 '22 22:08 michaelreneer

The current version requires a downgrade of tensorflow and tensorflow-probability package: !pip install --quiet tensorflow==2.8.0 !pip install --quiet tensorflow-probability==0.15.0 !pip install --quiet tensorflow-federated==0.20.0

HernandezEduin avatar Dec 28 '22 14:12 HernandezEduin

I did this and i got an error name python not defined when i tried the statement in google colab import tensorflow_federated as tff How to fix this

Sanmaryjoseph avatar Feb 14 '23 05:02 Sanmaryjoseph