Search code examples
tensorflowcallbackgoogle-colaboratorytensorboard

import import tensorflow_docs error on Colab


I've been using colab for deep learning for a over a month and all of a sudden import tensorflow_docs as tfdocs stopped working. Is anyone encountering the same issues???

I'm running tf.version 2.8.2

> !pip install git+https://github.com/tensorflow/docs
> 
> import tensorflow_docs as tfdocs   
> import tensorflow_docs.modeling   
> import tensorflow_docs.plots

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-8469b6568dc0> in <module>()
      2 get_ipython().system('pip install git+https://github.com/tensorflow/docs')
      3 
----> 4 import tensorflow_docs as tfdocs
      5 import tensorflow_docs.modeling
      6 import tensorflow_docs.plots

4 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_docs/api_generator/reference_resolver.py in ReferenceResolver()
     86       py_module_names: Union[list[str], dict[str, str]],
     87       link_prefix: Optional[str] = None,
---> 88       physical_path: Optional[dict[str, str]] = None,
     89   ):
     90     """Initializes a Reference Resolver.

TypeError: 'type' object is not subscriptable

UPDATE 01-Sep-2022

I updated python in colab to 3.9.1 using @Kor suggestion and confirmed it. Then ran:

> !pip install git+https://github.com/tensorflow/docs
> 
> import tensorflow_docs as tfdocs 

The tensorflow doc completed installation but still threw an error on import:

ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-15-2bc3446903cd> in <module>
    ----> 1 import tensorflow_docs as tfdocs
          2 import tensorflow_docs.modeling
          3 import tensorflow_docs.plots
          4 
          5 print("Version: ", tf.__version__)

    ModuleNotFoundError: No module named 'tensorflow_docs'

Solution

  • You can try this:

    !pip install -q git+https://github.com/MJAHMADEE/docs
    import tensorflow_docs as tfdocs   
    import tensorflow_docs.modeling   
    import tensorflow_docs.plots