简体   繁体   中英

ModuleNotFoundError: No module named 'tensorflow_data_validation' in Google Colab

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]

How to resolve this issue?

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM