卓特视觉
AI生成视频

Comfyui节点primitive-types导入失败报错“ImportError: cannot import name ‘NotRequired’ from ‘typing’”的解决办法!

PS:解决了这个问题,我个人comfyui环境中安装的165个插件节点,算是全部无冲突导入成功了!

Comfyui节点primitive-types由于作者长期不更新,在最新版本的comfyui中已经无法正常导入,会提示一个错误ImportError: cannot import name 'NotRequired' from 'typing'

虽然本人不会编程不懂代码,但是在deepseek的协助下,还是解决了这个报错,最终解决办法如下:

①找到插件目录文件”ComfyUI-aki-v1.3\custom_nodes\primitive-types\src\primitivetypes\base.py”

②将第二行代码

from typing import Any, Generic, Literal, NotRequired, TypedDict, TypeVar

修改为

from typing import Any, Generic, Literal, TypedDict, TypeVar
from typing_extensions import NotRequired # 使用扩展库

③将第10行代码

class NumberInputDict(TypedDict, Generic[Number]):

修改为

class NumberInputDict(TypedDict):
value: Number
enforce: NotRequired[bool]

④重启comfyui,报错消失,正常导入primitive-types节点!

当然,请确保你Python环境中已安装typing-extensions依赖。如无安装,请运行

pip install –upgrade typing-extensions

Comfyui节点primitive-types导入失败报错“ImportError: cannot import name 'NotRequired' from 'typing'”的解决办法!
© 版权声明

相关文章