Subject: ImportError when running a Towhee operator locally #2502
Unanswered
liaoran321
asked this question in
Q&A
Replies: 1 comment
-
You can refer to this: https://github.com/towhee-io/towhee/tree/main/tests/unittests/mock_operators/add |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I'm trying to develop a Towhee operator locally, but I'm running into an error that I can't seem to resolve. Whenever I try to run my operator script with python test_add.py, I get an ImportError with the following traceback:
arduino
Copy code
Traceback (most recent call last):
File "test_add.py", line 2, in
from towhee.types import DataType, DataShape
ImportError: cannot import name 'DataType' from 'towhee.types' (F:\Towhee\towhee_env\lib\site-packages\towhee\types_init_.py)
I've checked that Towhee is installed correctly in my virtual environment, and I've followed the steps in the Towhee documentation to create my operator. However, it seems like the DataType and DataShape classes cannot be imported from the towhee.types module.
Here's my operator code in test_add.py:
python
Copy code
from towhee.operator import PyOperator, SharedType
from towhee.types import DataType, DataShape
class TestAdd(PyOperator):
def init(self, factor: int):
super().init()
self._factor = factor
Can someone help me figure out what's causing this error? I'd really appreciate any suggestions or advice on how to resolve it.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions