'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.
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)
The error:
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_14604/719215164.py in <module>
1 import os
2 from tfx.components import CsvExampleGen
----> 3 from tfx.utils.dsl_utils import external_input
4 base_dir = os.getcwd()
5 data_dir = os.path.join(os.pardir, "data")
ModuleNotFoundError: No module named 'tfx.utils.dsl_utils'
I did full installation of tfx in which all packages are compatible. Any help is appreciated.
Solution 1:[1]
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. Just specify the folder name directly (or the path to the data folder).
Solution 2:[2]
Instead of using 'external_input', send data_dir directly into the 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 exist.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Aditya |
| Solution 2 | KMM |
