[英]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.我尝试通过 Google Colab 中的以下命令导入 Tensorflow 数据验证库。
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.我尝试通过以下命令使用 pip 安装库。 But couldn't install the package successfully.
但是无法成功安装 package。
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:要正确安装库,请按照下列步骤操作:
Install the library using pip:使用 pip 安装库:
!pip install tensorflow-data-validation
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".一个按钮将显示在前一个单元格的末尾以
Restart
,但您也可以使用Ctrl + M或使用菜单:“运行时”>“重启运行时”。
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.这是因为安装
tensorflow-data-validation
会升级您的 Colab 环境中已经存在的库之一。 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.我能够通过以下命令安装 tensorflow_data_validation 库来解决此错误。 Now I'm able to use this library in my Colab file.
现在我可以在我的 Colab 文件中使用这个库了。
!pip install -U tensorflow \
tensorflow-data-validation \
apache-beam[gcp]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.