Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsupported operand type(s) for |: '_GenericAlias' and 'NoneType' #85

Open
chabbly opened this issue Sep 19, 2024 · 3 comments
Open

unsupported operand type(s) for |: '_GenericAlias' and 'NoneType' #85

chabbly opened this issue Sep 19, 2024 · 3 comments

Comments

@chabbly
Copy link

chabbly commented Sep 19, 2024

Thanks for the great custom nodes! I am getting this error after installing and import is failing:

comfyui/ComfyUI/custom_nodes/ComfyUI_Custom_Nodes_AlekPet module for custom nodes: unsupported operand type(s) for |: '_GenericAlias' and 'NoneType'

@AlekPet
Copy link
Owner

AlekPet commented Sep 19, 2024

Hi. Can you give more information about the error. And what is the python version, please update it to 3.10 or higher.

@chabbly
Copy link
Author

chabbly commented Sep 20, 2024

I am using python 3.8.5 to juggle a different dependency -- perhaps that is the issue.

I think this is the full error message:

Traceback (most recent call last):
File "/home/users/u6933473/chatGPT_analysis/comfyui/ComfyUI/nodes.py", line 1994, in load_custom_node
module_spec.loader.exec_module(module)
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/users/u6933473/chatGPT_analysis/comfyui/ComfyUI/custom_nodes/ComfyUI_Custom_Nodes_AlekPet/init.py", line 284, in
from .GoogleTranslateNode.google_translate_node import (
File "/home/users/u6933473/chatGPT_analysis/comfyui/ComfyUI/custom_nodes/ComfyUI_Custom_Nodes_AlekPet/GoogleTranslateNode/google_translate_node.py", line 6, in
from googletrans import Translator, LANGUAGES
File "/home/users/u6933473/chatGPT_analysis/env/lib/python3.8/site-packages/googletrans/init.py", line 7, in
from googletrans.client import Translator
File "/home/users/u6933473/chatGPT_analysis/env/lib/python3.8/site-packages/googletrans/client.py", line 22, in
from googletrans.models import Translated, Detected, TranslatedPart
File "/home/users/u6933473/chatGPT_analysis/env/lib/python3.8/site-packages/googletrans/models.py", line 25, in
class Translated(Base):
File "/home/users/u6933473/chatGPT_analysis/env/lib/python3.8/site-packages/googletrans/models.py", line 42, in Translated
parts: List[TranslatedPart] | None,
TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'NoneType'

Cannot import /home/users/u6933473/chatGPT_analysis/comfyui/ComfyUI/custom_nodes/ComfyUI_Custom_Nodes_AlekPet module for custom nodes: unsupported operand type(s) for |: '_GenericAlias' and 'NoneType'Node -> PainterNode: PainterNode [Loading]

[END] ComfyUI AlekPet Nodes

@AlekPet
Copy link
Owner

AlekPet commented Sep 20, 2024

Hi. I looked at the logs, the whole point is that python 3.8 does not support union type "|" (https://peps.python.org/pep-0604/#add-a-new-operator-for-union-type1-type2), https://stackoverflow.com/a/76712732/23512000 . As an option, I already wrote above, update the python version to 3.10 or higher.

  • Or remove module googletrans from the environment (/home/users/u6933473/chatGPT_analysis/env) and install the version https://github.com/ssut/py-googletransor . Or install version old version on your environment pip install googletrans==3.1.0a0
  • Or edit the code in the file "/home/users/u6933473/chatGPT_analysis/env/lib/python3.8/site-packages/googletrans/models.py" line 42
parts: List[TranslatedPart] | None

to this

from typing import List, Union
parts: Union[List[TranslatedPart], None] = None
  • Or as an option, remove the GoogleTranslateNode (if it is not needed) by cutting the code from my __init__.py file and deleting the folder in /custom_nodes/ComfyUI_Custom_Nodes_AlekPet/GoogleTranslateNode

PS: It is best to update the python version, because the problem is not in my nodes, but in the version googletrans library, which does not support versions below 3.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants