Home > OS >  ModuleNotFoundError: No module named 'tensorflow_data_validation' in Google Colab
ModuleNotFoundError: No module named 'tensorflow_data_validation' in Google Colab

Time:03-21

I tried to import Tensorflow Data Validation library via the below command in Google Colab.

import tensorflow_data_validation as tfdv

It gave me this error:

ModuleNotFoundError: No module named 'tensorflow_data_validation'

I tried to install the library using pip via below commands. But couldn't install the package successfully.

 pip install tensorflow-data-validation

 pip install tensorflow-data-validation==1.3.0

 pip install --upgrade --force-reinstall tensorflow-data-validation[all]

Great if anyone could suggest a way on how to resolve this issue, so that I can make use of tensorflow_data_validation library in my Colab file.

CodePudding user response:

To install the library properly, follow these steps:

  1. Install the library using pip:

    !pip install tensorflow-data-validation
    
  2. Reload the environment. A button will show up at the end of the previous cell to Restart, but you can also do it with Ctrl M or using the menu: "Runtime" > "Restart Runtime".

  3. Import the library as usual:

    import tensorflow_data_validation as tfdv
    

Why do I need to reload the environment? It's because installing tensorflow-data-validation upgrades one of the libraries already present in your Colab environment. So, to "activate" the new environment and use the newly installed libraries and their installed versions you need to reload the environment

CodePudding user response:

I was able to resolve this error by installing tensorflow_data_validation library via the below command. Now I'm able to use this library in my Colab file.

!pip install -U tensorflow \
            tensorflow-data-validation \
            apache-beam[gcp]
  • Related