0

Hello i'm working on google colab and i have an issue with importing tensorflow_federated as tff it was working fine earlier and i don't know what is the problem now.

here is my code: I installed all the nessacery pip libaries and everything was working fine with version 0.20.0 of tff. I also tried to install the latest version 0.33.0 but it's not working could anyone help me please what is wrong???

!pip install --quiet --upgrade tensorflow-federated
!pip install --quiet --upgrade tensorflow-model-optimization
!pip install --quiet --upgrade nest-asyncio

import nest_asyncio
nest_asyncio.apply()
%load_ext tensorboard
!pip install h5py
!pip install typing-extensions
!pip install wheel
!pip install tensorflow
!pip install --quiet tensorflow-federated==0.20.0

here is my imports:

import pandas as pd 
import collections 
import numpy as np
np.random.seed(0)
import tensorflow as tf
from tensorflow.python.keras.optimizer_v2 import gradient_descent
import tensorflow_federated as tff
from random import choices
import matplotlib.pyplot as plt
from google.colab import drive 
import functools
from absl import app
from absl import flags
from absl import logging
import abc
from typing import Any, Callable, Iterable, List, Optional, Sequence, Tuple, Union
from tensorflow_federated.python.common_libs import py_typecheck

here is my error when i try to import tff :

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-17-bcd46adc5a91> in <module>
      5 import tensorflow as tf
      6 from tensorflow.python.keras.optimizer_v2 import gradient_descent
----> 7 import tensorflow_federated as tff
      8 from random import choices
      9 import matplotlib.pyplot as plt

/usr/local/lib/python3.7/dist-packages/tensorflow_federated/__init__.py in <module>
     79 # the directory structure. The python import statements above implicitly add
     80 # these to locals().
---> 81 del python  # pylint:disable=undefined-variable
     82 del proto  # pylint:disable=undefined-variable

NameError: name 'python' is not defined

Also there is an error when i try the first pip:

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. pymc 4.1.4 requires cachetools>=4.2.1, but you have cachetools 3.1.1 which is incompatible. grpcio-status 1.48.2 requires grpcio>=1.48.2, but you have grpcio 1.46.5 which is incompatible. google-colab 1.0.0 requires portpicker~=1.3.1, but you have portpicker 1.5.2 which is incompatible. google-cloud-bigquery 3.3.6 requires grpcio<2.0dev,>=1.47.0, but you have grpcio 1.46.5 which is incompatible.

ASh
  • 3
  • 1
  • Hi @ASh, could you please tell us which version of tensorflow you are using in colab? Thank You. –  Dec 22 '22 at 03:41

1 Answers1

0

as stated in the documentation here Tff tutorials

It is stated that tff required Python 3.9, while Google Colab current version are running on Python 3.8.16

Colab python version

You could try to run it on your local machine instead, or upgrade the python colab version to 3.9 --here's how to upgrade

xvrd13
  • 1