简体   繁体   English

"ModuleNotFoundError:没有名为“tfx.utils.dsl_utils”的模块"

[英]ModuleNotFoundError: No module named 'tfx.utils.dsl_utils'

I did install tfx version 1.2.1 Python: 3.8.2 Tensorflow: 2.5.2 pip: 21.3.1 I use window and installed the package through pip.我确实安装了 tfx 版本 1.2.1 Python:3.8.2 Tensorflow:2.5.2 pip:21.3.1 我使用窗口并通过 pip 安装了包。

The error occurred when I did:我这样做时发生了错误:

import os
from tfx.components import CsvExampleGen
from tfx.utils.dsl_utils import external_input
base_dir = os.getcwd()
data_dir = os.path.join(os.pardir, "data")
examples = external_input(os.path.join(base_dir, data_dir))
example_gen = CsvExampleGen(input=examples)
context.run(example_gen)

Instead of using 'external_input', send data_dir directly into the CsvExampleGen不使用“external_input”,而是将 data_dir 直接发送到 CsvExampleGen

import os
from tfx.components import CsvExampleGen
base_dir = os.getcwd()
data_dir = os.path.join(os.pardir, "data")
example_gen = CsvExampleGen(input_base='data_dir')

This has worked for me, looks like in tfx version 1._ , the module tfx.utils.dsl_utils doesn't exists.这对我有用,看起来在 tfx 版本 1._ 中,模块 tfx.utils.dsl_utils 不存在。

Just do the below:只需执行以下操作:

# Example 1
context= InteractiveContext()
from tfx.components import CsvExampleGen
example_gen = CsvExampleGen(input_base='data')
context.run(example_gen)

data is the folder that you would have downloaded from the author's github. data 是您从作者的 github 下载的文件夹。 Just specify the folder name directly (or the path to the data folder).只需直接指定文件夹名称(或数据文件夹的路径)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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